Python Email Automation: Send 1,000 Personalized Emails in 5 Minutes
Still manually sending emails in 2026? Here is the script that runs my outreach on autopilot.
Core Email Sender
import smtplib, csv, time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_bulk_emails(csv_file, sender_email, app_password):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, app_password)
sent = 0
with open(csv_file) as f:
for row in csv.DictReader(f):
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = row['email']
msg['Subject'] = f"Quick question for {row['name']}"
body = f"Hi {row['name']}, I built something for {row['business_type']} owners like you."
msg.attach(MIMEText(body, 'plain'))
server.sendmail(sender_email, row['email'], msg.as_string())
sent += 1
time.sleep(0.1)
server.quit()
return sent
Auto-Follow-Up (3 Days Later)
from datetime import datetime, timedelta
import sqlite3
def check_followups():
conn = sqlite3.connect('email_tracking.db')
c = conn.cursor()
cutoff = (datetime.now() - timedelta(days=3)).isoformat()
c.execute(
'SELECT id, to_email FROM emails WHERE sent_at < ? AND replied = 0 AND followup_sent = 0',
(cutoff,)
)
return c.fetchall()
Setup Gmail App Password
- Enable 2-Factor Auth on Gmail
- Google Account -> Security -> App passwords
- Create "Mail" app password
- Use that password in the script (never your main password)
Scheduling
0 9 * * 1 /usr/bin/python3 email_sender.py
Results in My Business
- Response rate: 8.3% (vs 2-3% industry average)
- Time saved: 12 hours/week
- Cost: $0 (vs Mailchimp $99/month for 10K contacts)
The full version with HTML templates, tracking pixels, bounce handling, and unsubscribe management is in the toolkit below.
Get 50+ Python automation scripts for $9: Python Business Automation Toolkit
Top comments (0)