A simple command-line Python tool to send emails using Flask-Mail.
This project demonstrates how to configure and use Flask-Mail to send emails via Gmail's SMTP server, with credentials loaded securely from environment variables.
- Send plain text emails using a Gmail account.
- CLI-based input (no HTML or frontend needed).
- Uses a
.envfile for credentials.
git clone https://github.com/M2hmoud2del/flask_email_sender.git
cd flask_email_senderpython -m venv venv
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtCreate a file named .env in the root of the project and add your Gmail credentials:
MAIL_USERNAME=your_email@gmail.com
MAIL_PASSWORD=your_app_passwordImportant: If you have 2FA enabled on your Gmail account, you will need to use an App Password instead of your regular password. You can generate one from your Google Account settings.
Run the program:
python app.pyYou will be prompted to enter:
- Recipient email
- Email subject
- Email body
Example:
Recipient Email: test@example.com
Subject: Hello
Message Body: This is a test email.
flask_email_sender/
├── app.py # Main script to send email
├── .env # Environment variables
├── requirements.txt # Python dependencies
└── README.md # Project documentation
This project is open source and free to use under the MIT License.
Developed by Mahmoud Adel GitHub: https://github.com/M2hmoud2del
LinkedIn: https://www.linkedin.com/in/mahmoud2del