This Python script sends personalized emails with attachments using Gmail's SMTP server. It loads recipient information from a csv and email configuration allowing customization of email content, recipients, and attachment files.
Before running the script, ensure you have:
- Python 3.x installed (Download Python). I'm using 3.9
- A Gmail account with 2-Step Verification enabled and an App Password generated
-
Clone the repository:
git clone https://github.com/vaibhava17/auto-mailer.git cd auto-mailer
-
Install dependencies:
pip install requirements.txt
-
Create a
.env
file: Create a file named.env
in the root directory with your Gmail account credentials:EMAIL_USER=your_email@gmail.com EMAIL_PASSWORD=your_generated_app_password EMAIL_SUBJECT=your_subject EMAIL_FROM=your_from_email EMAIL_ATTACHMENT=your_attachment_file_path CSV_FILE=your_data_file_path
-
Prepare
content.json
: Create acontent.json
file in the root directory with the following structure:{ "body": "Hi, \n\nThis is My content here." }
Run the script main.py
to send personalized emails:
python main.py
- Ensure that
python-dotenv
is installed (pip install python-dotenv
) to load environment variables from.env
. - Customize
content.json
to adjust email content as per your requirements. - Make sure your Gmail account allows access to less secure apps or has 2-Step Verification enabled with the app password.
This project is licensed under the MIT License - see the LICENSE file for details.