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.
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.
- Must contain a table structure (
<tbody>) - First column → Name
- Second column → Email
- Each row represents a participant
- Contains certificate images
- Naming format:
username.jpg - Username = email before
@
Example:
john_doe@gmail.com → john_doe.jpg
Update these variables in the script:
Replace:
PARTICIPANT_FILE = "partc.html"
With:
PARTICIPANT_FILE = "your_file.html"
Replace:
CERT_FOLDER = "certificates"
With:
CERT_FOLDER = "your_folder"
Replace:
LOG_FILE = "send_log.csv"
With:
LOG_FILE = "your_log.csv"
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 """
Run script with:
python bs.py --from-email your_email@gmail.com --app-pass your_app_password
pip install beautifulsoup4 lxml
(Note: Script auto-installs missing dependencies)
python bs.py --from-email your_email@gmail.com --app-pass your_app_password
python bs.py --from-email your_email@gmail.com --app-pass your_app_password --dry-run
- 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
Each user receives:
- Personalized email
- Certificate attachment
- Download link
Contains:
- Name
- Certificate file
- Status
- Timestamp
- Attempts
- Error message
- Install missing dependencies
- Parse HTML file
- Extract participant data
- Remove duplicate emails
- Load sent email log
- Match certificate files
- Build email message
- Send email with retries
- Log result
- Apply pause logic
You can modify these constants:
MAX_RETRIES = 3
RETRY_DELAY = 5
PAUSE_AFTER = 5
PAUSE_SECONDS = 10
SLEEP_BETWEEN = 1.0
.
├── bs.py
├── your_file.html
├── your_folder/
│ ├── user1.jpg
│ ├── user2.jpg
│ └── ...
└── (auto-generated) send_log.csv
- 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
Free to use and modify.