Skip to content

iamskp99/auto-mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Mail

Python script to send personalized cold emails via SMTP from a CSV file. Perfect for job hunting outreach.

Features

  • Template-based emails: Choose templates based on is_recruiter column (1 = recruiter.md, 0 = default.md)
  • Markdown templates: Write templates in Markdown format, automatically converted to HTML emails
  • Personalization: Use placeholders like {{name}}, {{company}}, {{job_link}}, {{position_name}} in templates
  • Custom templates: Override template selection with a single custom template file
  • Attachments: Attach files (e.g., resume) to all emails
  • Rate limiting: Configurable delay between emails to avoid spam filters

Setup

1. Environment Variables

Set your SMTP credentials (recommended):

export SMTP_USER="your-email@gmail.com"
export SMTP_PASSWORD="your-app-password"
# Optional (defaults shown):
export SMTP_HOST="smtp.gmail.com"
export SMTP_PORT="587"
export RESUME_PATH="PATH"

Or use the .env file:

source .env

2. Email Provider Setup

  • Gmail: Use an App Password, not your normal password
  • Outlook/Hotmail: Use smtp.office365.com, port 587, and your Microsoft account

Usage

Quick Start

  1. Prepare your CSV file (see format below)
  2. Edit templates in templates/default.txt and templates/recruiter.txt
  3. Run the script:
python send_mail.py

The script will prompt you for:

  • CSV file path
  • Custom template file (optional; press Enter to use default/recruiter templates)
  • Delay between emails in seconds (default: 60)

CSV Format

Your CSV must have these columns:

Column Required Description
email Yes Recipient email address
name Yes Recipient name (used in {{name}})
company Yes Company name (used in {{company}})
is_recruiter Yes 1 for recruiter template, 0 for default template
job_link No Job posting URL (used in {{job_link}})
position_name No Job title (used in {{position_name}})

Example CSV (contacts.example.csv):

email,name,company,is_recruiter,job_link,position_name
recruiter1@company.com,Jane Smith,Acme Inc,1,https://careers.company.com/job/123,Senior Software Engineer
hiring@startup.io,Alex Lee,Startup.io,0,https://startup.io/careers/eng,Backend Developer

Note: You can add any other columns to your CSV and use them as placeholders (e.g., {{custom_column}}).

Templates

Templates are located in the templates/ directory:

  • templates/default.md: Used when is_recruiter=0 (or missing)
  • templates/recruiter.md: Used when is_recruiter=1

Template Format (Markdown):

  • First line = Email subject (plain text)
  • Remaining lines = Email body (Markdown format, automatically converted to HTML)

Placeholders (case-insensitive):

  • {{name}} → Recipient name from CSV
  • {{company}} → Company name from CSV
  • {{job_link}} → Job link from CSV (empty if missing)
  • {{position_name}} → Position name from CSV (empty if missing)
  • {{email}} → Recipient email
  • Any other CSV column → {{column_name}}

Markdown Formatting: Templates use Markdown syntax, which is automatically converted to HTML for emails.

Supported Markdown:

  • **text** or __text__Bold text
  • *text* or _text_Italic text
  • [link text](url) → Hyperlink
  • # Heading → Large heading
  • ## Heading → Medium heading
  • ### Heading → Small heading
  • Empty line → Paragraph break

Example Template (templates/default.md):

Introduction – Shashank Kumar Pandey | Software Developer

Hi {{name}},

I hope you are doing well. My name is **Shashank Kumar Pandey** and I am a **SDE 2** at Landmark Group, having an experience of more than 3 years. 

I came to know that **{{company}}** is currently hiring for Software Engineering positions.

If possible, can you please refer the following position :
{{job_link}}

I have attached my resume for your reference.

Regards

Shashank Kumar Pandey

You can edit the templates as you wish.

Note: All templates are automatically converted from Markdown to HTML, so emails are always sent as HTML with proper formatting.

Custom Template

When prompted for "Custom template file", you can provide a path to a template file. This template will be used for all rows, ignoring the is_recruiter column.

How It Works

  1. Reads the CSV file
  2. For each row:
    • Determines template: recruiter.txt if is_recruiter=1, else default.txt (or custom template if provided)
    • Replaces placeholders ({{name}}, {{company}}, etc.) with values from the CSV row
    • Sends the email via SMTP
    • Waits for the specified delay before processing the next row

Requirements

  • Python 3.9+
  • Standard library only (no external dependencies)

Troubleshooting

"SMTP username and password required"

  • Make sure you've set SMTP_USER and SMTP_PASSWORD environment variables

"CSV must have a column named 'email'"

  • Check that your CSV has an email column (case-sensitive)

Emails not sending

  • Verify SMTP credentials
  • Check firewall/network settings
  • For Gmail, ensure you're using an App Password, not your regular password

License

Free to use for personal and commercial purposes.

About

Python script to send personalized cold emails via SMTP from a CSV file. Perfect for job hunting outreach.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages