This is a simple Python script for sending personalized emails to a list of contacts using Gmail's SMTP server. The script supports the use of environment variables for storing sensitive information like email credentials.
- Sends emails to multiple contacts listed in a
contacts.txt
file. - Uses a customizable email template from a
message.txt
file. - Supports placeholders in the template for personalized content.
- Credentials are loaded securely from a
.env
file. - Basic error handling for missing data and invalid contact entries.
- Python 3.x
smtplib
(built-in Python library)python-dotenv
(to load environment variables)
-
Clone this repository:
git clone https://github.com/kayceenuel/emailer.git cd emailsender
-
Install the required Python package:
pip install python-dotenv
-
Create a
.env
file in the project directory and add your Gmail credentials:[email protected] PASSWORD=your-app-password
-
Prepare your
contacts.txt
file with the email addresses and personalized data:[email protected], Name1, AdditionalData1 [email protected], Name2, AdditionalData2
-
Create your
message.txt
file with the email subject and body:Subject Line Here Dear {0}, Your personalized message goes here. Your additional data: {1}. Best regards, Your Name
Run the script with Python:
python main.py