Send Personalized Cold Emails

Upload a CSV and send emails in bulk using templates.

Details

How it works

This script reads a CSV of contacts, fills in a template, and sends personalized emails using SMTP.

Python


        import csv
import smtplib
from email.message import EmailMessage
from string import Template
from pathlib import Path

EMAIL_ADDRESS = "oussamachahidi20@gmail.com"
EMAIL_PASSWORD = "vfyk ojkj dsiu wgfu"
SMTP_SERVER = "smtp.gmail.com"
SMTP_PORT = 587

template_path = Path("template.txt")
template = Template(template_path.read_text())

with open("clients.csv", newline='', encoding="utf-8") as csvfile:
    reader = csv.DictReader(csvfile)
    clients = list(reader)

with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as smtp:
    smtp.starttls()
    smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)

    for client in clients:
        msg = EmailMessage()
        content = template.substitute(client)
        lines = content.strip().split("
", 1)
        subject = lines[0].replace("Subject:", "").strip()
        body = lines[1].strip()

        msg["Subject"] = subject
        msg["From"] = EMAIL_ADDRESS
        msg["To"] = client["email"]
        msg.set_content(body)

        try:
            smtp.send_message(msg)
            print(f"✅ Sent to {client['name']} ({client['email']})")
        except Exception as e:
            print(f"❌ Failed to send to {client['email']}: {e}")