π€ Intelligent Automated Email Delivery System with Google Sheets Integration
Features β’ Getting Started β’ Project Structure β’ Configuration β’ Usage β’ Contributing
Email Bot is a sophisticated Python-based automation system that seamlessly integrates with Google Sheets to manage and send personalized emails. The system intelligently handles Birthday wishes, Festival greetings, Welcome emails, and Scheduled custom messages with template support, secure delivery, and simplified communication management.
- π Automatic Birthday Reminders - Never miss a birthday again!
- π Festival Greetings - Send festival wishes automatically
- π Welcome Emails - Personalized welcome messages for new users
- π Scheduled Messages - Custom emails on specific dates
- π Secure Email Validation - Domain & MX record verification
- π Google Sheets Sync - Centralized recipient management
- π Template Support - Beautiful HTML email templates
- π Activity Logging - Comprehensive system logs & statistics
- π¨ Colorful Console Output - Interactive terminal feedback
| Feature | Description | Status |
|---|---|---|
| π Google Sheets Integration | Fetch recipient data from Google Sheets | β Active |
| π Birthday Automation | Send birthday greetings on configured dates | β Active |
| π Festival Notifications | Automated festival wishes distribution | β Active |
| π§ HTML Email Templates | Customizable email templates with placeholders | β Active |
| π Email Validation | DNS/MX record verification for email addresses | β Active |
| π Activity Tracking | Log all sent emails and system activities | β Active |
| βοΈ Environment Configuration | Secure credentials management via .env | β Active |
| π‘οΈ Error Handling | Comprehensive exception handling & logging | β Active |
π¦ python-dotenv - Environment variable management
π¦ colorama - Colorful terminal output
π¦ dnspython - DNS resolution for email validation
π¦ google-auth - Google authentication
π¦ google-api-python-client - Google Sheets API integration
- π’ Google Sheets API - Data source management
- π§ Gmail SMTP - Email delivery (smtp.gmail.com:465)
- π Google OAuth 2.0 - Secure authentication
email-bot/
βββ π task01.py # Daily automation task (Birthdays & Festivals)
βββ π task02.py # Additional email tasks
βββ π service.py # Core service module (Email, Auth, Utils)
βββ π requirements.txt # Python dependencies
βββ π .gitignore # Git ignore rules
β
βββ π Module/ # Utility modules
β βββ setup_logger.py # Logging configuration
β βββ calendar.py # Festival & birthday filtering
β βββ google_sheet.py # Google Sheets operations
β
βββ π Template/ # HTML email templates
β βββ Birthday_Wishing_Mail.html
β βββ Festival_Mail.html
β βββ Thank_You_Mail.html
β βββ Two_Factor_Authentication.html
β
βββ π Data/ # Data storage
β βββ data.json # Recipients database
β βββ festivals.json # Festival calendar
β
βββ π Logs/ # System logs
β βββ email_bot.log # Application logs
β
βββ π Secure/ # Configuration (β οΈ Not in repo)
βββ credentials.json # Google Sheet credential file
βββ .env # Environment variables
- Python 3.8 or higher
- Google Account with Sheets API enabled
- Gmail Account (for SMTP)
- Git
git clone https://github.com/mairhythmhoon/email-bot.git
cd email-botpip install -r requirements.txt- Go to Google Cloud Console
- Create a new project
- Enable Google Sheets API and Google Drive API
- Create OAuth 2.0 credentials (Service Account)
- Download the JSON credentials file
- Place it in the
Secure/directory
Create a .env file in the Secure/ directory:
# Gmail Configuration
E_MAIL=your-email@gmail.com
PASSWORD=your-app-specific-password
RESPONS_MAILE=your-reply-to@gmail.com
# Google Sheets Configuration
GOOGLE_SHEETS_CREDENTIALS=path/to/credentials.json[
{
"Name": "John Doe",
"Email address": "john@example.com",
"Birthdate": "15/03/1995"
},
{
"Name": "Jane Smith",
"Email address": "jane@example.com",
"Birthdate": "22/08/1998"
}
][
{
"festival_name": "New Year",
"date": "01/01/2026"
},
{
"festival_name": "Diwali",
"date": "01/11/2026"
}
]python task01.pyThis will:
- π Fetch recipient data from Google Sheets
- π Check for birthdays and send wishes
- π Check for festivals and send greetings
- π Log activities to Google Sheets
- π Generate system logs
python task02.py# Edit crontab
crontab -e
# Add this line to run daily at 8 AM
0 8 * * * cd /path/to/email-bot && python task01.py- Open Task Scheduler
- Create a new task
- Set trigger: Daily at 8:00 AM
- Set action: Execute
python.exewith argumentC:\path\to\task01.py
The system supports customizable HTML email templates with dynamic placeholders:
{name}- Recipient's name{festival}- Festival name
<html>
<body>
<h1>Hello {name}! π</h1>
<p>Wishing you a wonderful {festival}!</p>
</body>
</html>- β
Use environment variables (
.envfile) - β
Never commit
.envto Git - β Use Gmail App-Specific Passwords (not your main password)
- β Keep credentials.json private
- β Regex pattern validation
- β MX record verification
- β Domain existence checking
- β Automatic error logging
- β Comprehensive try-catch blocks
- β Detailed logging system
- β Graceful failure recovery
- π Total emails sent
- π Birthday emails count
- π Festival emails count
- β Failed delivery attempts
- β° Execution timestamps
[2026-04-24 08:30:15] INFO: EMAIL SYSTEM STARTED
[2026-04-24 08:30:16] INFO: Fetching Data From Database
[2026-04-24 08:30:18] INFO: Birthday Today: John Doe
[2026-04-24 08:30:20] INFO: Email sent to john@example.com
[2026-04-24 08:30:21] INFO: EMAIL SYSTEM ENDED
| Issue | Solution |
|---|---|
| Gmail authentication fails | Ensure App-Specific Password is used, not your main password |
| Invalid email format error | Check email format in data.json |
| MX record lookup fails | Verify internet connection, domain may not exist |
| Google Sheets not syncing | Verify credentials.json and API permissions |
| Templates not loading | Ensure template files exist in Template/ directory |
| No emails sent | Check if dates in data.json match today's date |
View detailed logs in Logs/email_bot.log:
# View last 20 lines
tail -20 Logs/email_bot.log
# Watch logs in real-time
tail -f Logs/email_bot.logContributions are welcome! Here's how to help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- π§ Additional email templates
- π¨ Enhanced HTML designs
- π Internationalization (multi-language support)
- β‘ Performance optimizations
- π± SMS notification support
service.py - Core service module
- Email sending functionality (SMTP)
- Template loading and management
- Email validation with DNS lookup
- Google Sheets integration
- Logging and activity tracking
task01.py - Daily automation task
- Birthday checking and filtering
- Festival notification logic
- Statistics generation
- Google Sheets data sync
task02.py - Additional email operations
- Custom scheduled emails
- Bulk email sending
- User management tasks
- GitHub: @mairhythmhoon
- Email: rhythm.work.id@proton.me
- Instagram: @mairhythmhoon
- LinkedIn: @mairhythmhoon
This project is open source and available under the MIT License.
- Advanced scheduling with cron expressions
- Multi-language template support
- User preference management
- Automated email list segmentation