Skip to content

Python script to automate sending batch emails to my fans!

Notifications You must be signed in to change notification settings

karume-lab/pymailer

Repository files navigation

pymailer

A Python-based email sender for personalized newsletters using HTML templates, TXT content, and a recipient list. Supports inline images, HTML formatting, and plain-text fallback.


Project Structure

├── email-content.example.txt   # Example content file (subject + body)
├── email-list.example.txt      # Example recipient list
├── email-template.jinja        # HTML email template
├── README.md                   # This file
├── requirements.txt            # Python dependencies
└── src
    └── main.py                 # Main script to send emails

After setup:

.env                            # Environment variables
email-content.txt               # Your actual newsletter content
email-list.txt                  # Your actual recipient list
venv/                           # Python virtual environment

Features

  • Batch email sending
  • HTML emails with plain-text fallback
  • Simple file-based configuration

Setup Instructions

1. Clone the repository

git clone https://github.com/karume-lab/pymailer
cd pymailer

2. Create and activate a virtual environment

python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Copy .env.example to .env and fill in your SMTP credentials.

For Gmail, you must use an App Password with 2‑Step Verification enabled.


Preparing content and recipients

Instead of writing content directly in this README, pymailer uses example files as templates. Copy the example files and edit them for your own use.

1. Recipient list

Copy the example file:

cp email-list.example.txt email-list.txt

Edit email-list.txt to include one email address per line.


2. Email content

Copy the example content file:

cp email-content.example.txt email-content.txt

The format is:

  • First line: Email subject
  • Remaining lines: Email body (plain text)

Refer to email-content.example.txt for a complete working example.


3. HTML template

email-template.jinja defines the HTML layout for your email. The rendered email body will be injected using the {{ content }} placeholder.

You can customize styling and layout directly in this file.


Running the script

Run the main Python script:

python src/main.py

This will:

  • Load recipients from email-list.txt
  • Load subject and body from email-content.txt
  • Send an HTML email (with plain-text fallback) to each recipient

Notes

  • Always test with a small recipient list first
  • Double‑check SMTP credentials before large sends
  • This tool is intentionally minimal: it sends batch emails, nothing more, nothing less

About

Python script to automate sending batch emails to my fans!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published