Make it easy to send emails
Install from pypi:
pip install gmail-emailer
To use this library, you need to setup a gmail account to send the emails from. You can sign up normally, but then you also need to allow non-secure apps to connect to the account.
Update: As of May 2022, the process has changed. You should follow the instructions in this stackoverflow answer
from emailer.emailer import Emailer
emailer = Emailer(to_emails=['[email protected]'],
from_email='[email protected]',
from_email_password='your password')
html_str = '<html><body><p>this is an example</p></body></html>'
emailer.send_html_email(subject='Email subject',
sent_from='User Name',
message_html=html_str)
You can also attach images by incuding them in the send_html_email
method:
images = [ {'path': 'path/to/file.jpg', 'id': 'any identifier you want'} ]
emailer.send_html_email(..., images=images)