Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

send_email_python

Send HTML and attachment emails from Python using Gmail SMTP with TLS encryption.

Requirements

pip install secure-smtplib  # stdlib smtplib is included in Python

No external packages needed — uses Python's built-in smtplib, email, and ssl modules.

Setup

Gmail requires an App Password (not your regular account password):

  1. Enable 2-Factor Authentication on your Google account
  2. Go to Google Account → Security → App Passwords
  3. Generate a password for "Mail" → copy it
  4. Paste it as SENDER_PASSWORD in the script

Usage

SENDER_EMAIL = "[email protected]"
SENDER_PASSWORD = "your_16_char_app_password"
RECEIVER_EMAIL = "[email protected]"

Run:

python email.py

How it works

  • Connects to smtp.gmail.com:587
  • Upgrades to TLS via STARTTLS with a secure SSL context
  • Attaches an image (imgName.jpg) alongside the text body

About

Send emails with attachments from Python using Gmail SMTP and TLS

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages