raki
06/12/2023, 9:10 PMfrom prefect_email import EmailServerCredentials
credentials = EmailServerCredentials(
username="<mailto:your-email@example.com|your-email@example.com>",
password="your-app-password", # must be an app password
)
credentials.save("your-block-name")
and then on flow
# Load the email server credentials
email_credentials_block = EmailServerCredentials.load("your-block-name")
# Send an email
email_send_message(
email_server_credentials=email_credentials_block,
subject="Flow Notification",
msg="Flow run completed",
email_to=my_email,
)
Since I am on ec2, I need to push to my github so it will contain my gmail. How can I not expose it? I have not understood how it works apparently.
Edit: I figured it out!
I used
from dotenv import load_dotenv
import os
load_dotenv()
my_email = os.getenv("MY_EMAIL")
and then
export MY_EMAIL=email_you_want
without pushing the credentials block to github.
Is this the way or is there another one?