email-sender-automation tools built with python
Project description
๐ง Email Sender Automation
Automated bulk email sender built with Python and SMTP. Features recipient management via CSV, dynamic HTML templates with personalisation, configurable send intervals, retry logic, and a full delivery report with success/failure tracking.
๐ Table of Contents
- About the Project
- Features
- Project Structure
- Requirements
- Installation
- Configuration
- Usage
- Output
- Example CSV
- Example Email Template
- Error Handling
- License
๐ About the Project
This is a Python automation project that sends bulk marketing emails using the SMTP protocol. Instead of manually sending emails one by one, this tool reads a list of recipients from a CSV file, personalizes each email using an HTML template, and delivers them automatically โ while logging every result.
Built as part of a Python automation portfolio.
โจ Features
- โ Send bulk emails to hundreds or thousands of recipients
- โ
Personalize each email using
{{name}}placeholders - โ Read recipients from a CSV file
- โ HTML email template support
- โ Configurable delay between sends (avoid spam filters)
- โ Retry logic for failed sends
- โ Delivery summary printed to console
- โ
Full delivery log saved to
sent_log.csv - โ
Failed recipients saved to
failed_recipients.csv - โ
Credentials stored securely using
.env
๐ Project Structure
email-sender-automation/
โ
โโโ email_sender/ # Core package
โ โโโ __init__.py # Makes this a Python package
โ โโโ sender.py # Core SMTP send logic
โ โโโ template_renderer.py # Renders HTML template per recipient
โ โโโ logger.py # Logs sent/failed results to CSV
โ โโโ config.py # Loads .env settings
โ
โโโ data/ # Input files
โ โโโ contacts.csv # recipient list
โ โโโ template.html # email body template
โ
โโโ output/ # Auto-generated on run (gitignored)
โ โโโ sent_log.csv # Full delivery log
โ โโโ failed_recipients.csv # Failed sends for re-run
โ
โโโ tests/ # Unit tests
โ โโโ test_sender.py
โ โโโ test_template_renderer.py
โ
โโโ main.py # Entry point โ runs the automation
โโโ .env # SMTP credentials (never commit this)
โโโ .env.example # Example env file (safe to commit)
โโโ .gitignore # Ignores .env, output/, __pycache__
โโโ LICENSE # MIT License
โโโ pyproject.toml # Build system config
โโโ requirements.txt # Python dependencies
โโโ setup.py # Package setup for PyPI
โโโ README.md # Documentation (This file)
โ๏ธ Requirements
- Python 3.8+
- A Gmail account (or any SMTP provider)
- Gmail App Password (if using Gmail with 2FA)
๐ง Installation
- Clone the repository
pip install email-sender-automation
- Install dependencies
pip install -r requirements.txt
- Set up your
.envfile
cp .env.example .env
Then edit .env with your credentials:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SENDER_EMAIL=you@gmail.com
SENDER_PASSWORD=your_app_password_here
๐ Configuration
| Variable | Description | Example |
|---|---|---|
SMTP_HOST |
Mail server address | smtp.gmail.com |
SMTP_PORT |
SMTP port (TLS) | 587 |
SENDER_EMAIL |
Your sending email | you@gmail.com |
SENDER_PASSWORD |
App password or SMTP key | xxxx xxxx xxxx xxxx |
Usage
from email_sender_automation import send_email
send_email(
subject="Hello",
body="This is a test email",
recipients="recipient@example.com"
)
python main.py
python main.py --retry-failed
๐ Output
After the run completes, you will see a summary in the terminal:
==================================
EMAIL DELIVERY SUMMARY
==================================
Total recipients : 5000
Sent : 4873
Failed : 127
Success rate : 97.5%
Duration : 4m 12s
==================================
Log saved to : output/sent_log.csv
Failed saved to : output/failed_recipients.csv
==================================
sent_log.csv columns
| timestamp | recipient | subject | status | error |
|---|---|---|---|---|
| 2025-03-24 09:00:03 | alice@example.com | Spring Sale! | SENT | |
| 2025-03-24 09:00:05 | bad@@email.net | Spring Sale! | FAILED | SMTPRecipientsRefused |
๐ก๏ธ Error Handling
| Error | What happens |
|---|---|
| Invalid email address | Logged as FAILED, skipped |
| SMTP timeout | Retried up to 3 times |
| Auth failure | Script stops immediately with a clear message |
| Missing CSV column | Script stops immediately with a clear message |
๐ License
MIT License
Copyright (c) 2024 Anuja Khatri
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Built with Python ยท smtplib ยท Jinja2 ยท python-dotenv
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file email_sender_automation-0.1.0.tar.gz.
File metadata
- Download URL: email_sender_automation-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39abfddca15ef284e301d16fe0c43978138c070d5e8f686d82975f0888140d1a
|
|
| MD5 |
9166dfcf952a9e0910b134ee32112ca9
|
|
| BLAKE2b-256 |
2b0d625a1d8ff6daf58be6291c1800569a8f7511ec50547d6e8e32cfcb923b95
|
File details
Details for the file email_sender_automation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: email_sender_automation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a613293f9ea859390a4608925426b057969ddaf64bab0cacb59b207f117e3f0
|
|
| MD5 |
a06ed973d3601124a1000c7f708f2664
|
|
| BLAKE2b-256 |
908c81dc6a1edeba4d85a5389d55aed56f8c379a7f7f39a4c47d1fe536012743
|