Skip to content

psvineet/BatchMail-Cert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

BatchMail-Cert

Bulk Certificate Email Sender

A fully automated Python tool to send personalized certificates via email in bulk using participant data from an HTML file.

This tool integrates parsing, validation, email sending, retry handling, and logging into a single workflow.


Overview

This script automates the entire certificate distribution pipeline:

  • Parses participant data (name, email) from HTML
  • Matches certificates from a folder
  • Sends personalized emails with attachments
  • Skips already sent users using logs
  • Detects duplicate entries in HTML
  • Retries failed email deliveries
  • Generates detailed logs for tracking

Designed for large-scale event or certificate distribution.


Input Requirements

1. HTML File

  • Must contain a table structure (<tbody>)
  • First column → Name
  • Second column → Email
  • Each row represents a participant

2. Certificate Folder

  • Contains certificate images
  • Naming format:
    username.jpg
    
  • Username = email before @

Example:

john_doe@gmail.com → john_doe.jpg

⚠️ What You Need to Replace Before Running

Update these variables in the script:

1. Participant HTML File

Replace:

PARTICIPANT_FILE = "partc.html"

With:

PARTICIPANT_FILE = "your_file.html"

2. Certificate Folder

Replace:

CERT_FOLDER = "certificates"

With:

CERT_FOLDER = "your_folder"

3. Log File (Optional)

Replace:

LOG_FILE = "send_log.csv"

With:

LOG_FILE = "your_log.csv"

4. Customize Email Template

Inside the script, modify the email content in the build_message() function:

  • Edit subject line:
msg["Subject"] = "Your Subject Here"
  • Modify plain text message:
plain = "Your custom plain text message"
  • Modify HTML email template:
html = """ your custom HTML content """

5. Email Sender Credentials (CLI)

Run script with:

python bs.py --from-email your_email@gmail.com --app-pass your_app_password

Dependencies

pip install beautifulsoup4 lxml

(Note: Script auto-installs missing dependencies)


Usage

Normal Run

python bs.py --from-email your_email@gmail.com --app-pass your_app_password

Dry Run (No emails sent)

python bs.py --from-email your_email@gmail.com --app-pass your_app_password --dry-run

Features

  • Automatic dependency installation
  • HTML parsing using BeautifulSoup
  • Duplicate email detection
  • Skips already sent users via log file
  • Retry mechanism (3 attempts)
  • Automatic pause after batch sending
  • Email with HTML + attachment
  • Clean logging system

Output

Email Sending

Each user receives:

  • Personalized email
  • Certificate attachment
  • Download link

Log File (send_log.csv)

Contains:

  • Name
  • Email
  • Certificate file
  • Status
  • Timestamp
  • Attempts
  • Error message

Processing Flow

  1. Install missing dependencies
  2. Parse HTML file
  3. Extract participant data
  4. Remove duplicate emails
  5. Load sent email log
  6. Match certificate files
  7. Build email message
  8. Send email with retries
  9. Log result
  10. Apply pause logic

Configuration (Advanced)

You can modify these constants:

MAX_RETRIES = 3
RETRY_DELAY = 5
PAUSE_AFTER = 5
PAUSE_SECONDS = 10
SLEEP_BETWEEN = 1.0

Required Project Structure

.
├── bs.py
├── your_file.html
├── your_folder/
│   ├── user1.jpg
│   ├── user2.jpg
│   └── ...
└── (auto-generated) send_log.csv

Notes

  • Uses SMTP (Gmail recommended)
  • Requires App Password (not normal password)
  • Certificates must exist before sending
  • Duplicate entries are skipped automatically
  • Already sent users are skipped using log tracking
  • Safe for large batch processing

License

Free to use and modify.

About

A Python automation tool for bulk sending personalized certificates via email with retry handling, logging, and duplicate control.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages