For this task, I wanted to send an email through Python. I wrote a script that would allow me to send an email from a Gmail account I created for this purpose.
-
Python
-
HTML (very basic)
After determining what I felt was the most suitable library to import, I researched how to send the email and let the sender know the email had been sent successfully. This included:
- Overcoming the security features in Gmail that initially prevented me from being able to send an email
- A feedback response on the terminal to let the user know the email was sent
- My code was written for sending an email through Gmail
- The process might be different if you use a different email service provider
- Google takes steps to prevent less secure apps/sites from being able to access the Google Server. You can change the settings here: https://myaccount.google.com/apppasswords
- Due to security concerns, I set up a Gmail account (I didn’t use my personal account) for use with this script and removed any personal information from my published code:
- There are notes in the code to help you fill in the relevant parts
- Feel free to use my code, but ensure you remove any personal or sensitive information before publishing it
This is the first version of this script. I see a lot of potential for extending this script and in the future I look forward to researching and incorporating the following:
- Enhancing the HTML code
- Adding attachments
- Scheduling the emails to be sent at a certain time or with a certain frequency
- Linking to an API to get dynamic content
- For example, a weather API to tell me what the weather will be like today