Send an email using Python and Gmail
Send an email as simple as possible

Motivation
I’ve written a simple script for sending emails with just Python and Gmail account about year ago, but in a meantime, it stopped working. I discovered that different credentials are needed now in order to send mail via script.
So I wrote this short guide to explain which configuration is required now and how to make it work again.
Prerequisites
Configure Gmail


And now you will get the window with APP_PASSWORD
, which you’ll need to save, since it acts now like a password for access to Gmail via script.
Configure script
- Copy the file and save it as
send-email-python3-gmail.py
- Add config:
EMAIL
,APP_PASSWORD
,RECEIVER
,SUBJECT
,MESSAGE_TEXT
Run script
python3 send-email-python3-gmail.py
Conclusion
This is the simplest way to send an email without worrying about configuration of some external service like Sendgrid or AWS SES.
I hope it will be useful to someone.
Ping me on @ljmocic if you have any questions!
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
