Send emails¶
Ecodev-core provides a generic method to send emails.
In order for it to work, one has to specify the following environment variables:
email_smtp
: the smtp address of your smtp provider (smtp.gmail.com
) for gmail for instanceemail_sender
: the email address to be used to send emails.email_password
: theemail_sender
password. Documentation on how to do it via gmail.
Once this is done, the method signature looks like so:
send_email(email: str, body: str, topic: str, images: Dict[str, Path]) -> None:
where:
email
is the email address to which to send the emailbody
is the mail body to send. This can be a html file rendered with Jinja2topic
: is the email titleimages
: if any, the Dict of image tags:image paths to incorporate in the email