An open source function to send emails using Gmail (or other providers).
Requirements
- Gmail Account
- Python
- Pip
Setup
- Create a virtual environment
python -m venv venv
- Activate the virtual environment
./venv/scripts/activate
- Install requirements
pip install -r requirements.txt
- Replace EMAIL_FROM and app_password with your gmail (or other provider's) details. You can follow these instructions for Gmail
EMAIL_FROM = "youremail@gmail.com"
app_password = "000000000000" # you can create an app password from your gmail account security settings
- Replace "example@gmail.com" with the email to send
response = send_email("example@gmail.com", [], "Testing Function", "Hi there. It's working well")
- Run the function
python app.py