This script automatically sends personalized emails with:
- A fully formatted HTML email (with inline images such as the logo or icons)
- A ZIP file containing the recipient’s photos
- Gmail SMTP authentication
- Automatic JPEG renaming + ZIP creation
- Automatic archival of processed files
You must have Python 3.9+ installed.
Check your version:
python3 --versionIf missing, install Python from: https://www.python.org/downloads/
From the project root, run:
python3 -m pip install beautifulsoup4No other external packages are required (everything else is in the Python standard library).
Your repository should look like this:
/project-root
│
├── send_photos.py # Your script
├── email.html # HTML template for your email
├── Ephemere_Logo_Cropped_Black.png
├── icon_flickr.svg
├── icon_instagram.svg
├── icon_discord.svg
│
├── to_send/ # Input folder
│ ├── recipient1@email.com/
│ │ ├── photo1.jpg
│ │ ├── photo2.jpg
│ │ └── ...
│ ├── someone_else@gmail.com/
│ │ ├── ...
│ └── ...
│
└── sent/ # Auto-generated archive output
to_send/must exist.- Inside
to_send/, create a folder named exactly as the recipient's email address. - Put their
.jpg/.jpegphotos inside. - The script will rename, zip, send, then move the ZIP file into
/sent.
The script uses Gmail SMTP with an App Password.
Steps:
- Enable 2-factor authentication on your Google account
- Go to Security → App Passwords
- Generate a new password
- Paste it in the script:
GMAIL_ADDRESS = "SENDER_EMAIL"
GMAIL_APP_PASSWORD = "APP_PASSWORD"- Reads your HTML template
- Finds all
<img src="./..."> - Embeds them as inline images using CID
- Rewrites the HTML so images display correctly in email clients
For each folder inside to_send/:
-
Rename photos →
image_01.jpeg,image_02.jpeg, … -
ZIP the folder into
recipient_email.zip -
Send the email:
- HTML body
- Inline logo/icons
- ZIP attachment
-
Move the ZIP to
/sent
From the repo root:
python3 send_photos.pyYou will see logs like:
Processing example@gmail.com...
✅ Sent email to example@gmail.com
📦 Moved example@gmail.com and its zip to 'sent'
| Issue | Solution |
|---|---|
| Email images not displaying | Check <img src="./yourfile.ext"> paths and ensure the file exists next to email.html. |
| Gmail blocks the login | Make sure you're using an App Password, not your normal one. |
| Script finds no folders | Ensure to_send/ contains subfolders named after actual email addresses. |