Send Emails
Sending Emails
- To send emails, we need to make the credentials accessible to the Prefect agent. You can do that by creating the below file in
$HOME/.prefect/config.toml
.
[context.secrets]
EMAIL_USERNAME = "<Your email id>"
EMAIL_PASSWORD = "<your email password>"
from prefect.tasks.notifications.email_task import EmailTask
email_task = EmailTask(
subject="A new windspeed captured",
email_to="receiver_email@gmail.com",
email_from="your_email@gmail.com",
)
with Flow("Windspeed Tracker", schedule=schedule) as flow:
email_task(
msg=str(windspeed),
)