Absolutely — here's an alternative **classroom-style explanation with bullet
points, concepts, and a practical example** for sending **personalized emails one
by one with an attachment** using Python:
---
## 📚 Python Email Automation (With Attachments, Sent Individually)
---
### 🎯 Goal
> Send a **personalized email** with a **PDF resume attachment** to **each
recipient individually** using a Gmail account.
---
### 🧠 Key Concepts
* **SMTP**: Simple Mail Transfer Protocol (used to send emails)
* **App Password**: Required if Gmail has 2-Step Verification
* **EmailMessage**: Part of the `email` package, makes building MIME emails easier
* **Secure Connection**: Use `SMTP_SSL` on port `465`
---
### 🧾 Use Case
* You are reaching out to recruiters or companies
* Want to attach your resume
* Avoid sending all recipients in BCC (send one by one)
---
### 🔧 Prerequisites
1. Python installed (`3.6+`)
2. Gmail account
3. **App password** (from
[https://myaccount.google.com/apppasswords](https://myaccount.google.com/
apppasswords))
4. PDF resume in the same directory
---
### Python Code (Practical & Clean)
```python
import smtplib
from email.message import EmailMessage
import os
# --- Configuration ---
EMAIL_ID = '
[email protected]'
APP_PASSWORD = 'your_app_password'
RESUME_FILE = 'Ashish_Resume.pdf'
RECIPIENTS = [
'[email protected]',
'[email protected]',
'[email protected]'
]
SUBJECT = 'Exploring Opportunities | Backend Engineer at LendingKart'
BODY = """\
Hi,
I wanted to reach out to discuss potentially working together.
I’m a Backend Software Engineer at LendingKart and currently seeking new
opportunities.
PFA my resume for your reference.
LinkedIn: https://www.linkedin.com/in/ashish-singh-39127b288
Thanks & Regards,
Ashish Singh
"""
# --- Function to send mail ---
def send_email(to_email):
try:
msg = EmailMessage()
msg['Subject'] = SUBJECT
msg['From'] = EMAIL_ID
msg['To'] = to_email
msg.set_content(BODY)
with open(RESUME_FILE, 'rb') as file:
msg.add_attachment(
file.read(),
maintype='application',
subtype='pdf',
filename=os.path.basename(RESUME_FILE)
)
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ID, APP_PASSWORD)
smtp.send_message(msg)
print(f"✅ Email sent to {to_email}")
except Exception as error:
print(f"❌ Failed to send to {to_email}: {error}")
# --- Iterate over recipients ---
for email in RECIPIENTS:
send_email(email)
```
---
### Notes
* **Don't hardcode** your email/password in production — use `.env` or a config
file
* Gmail has a **limit** on how many emails you can send/day (\~100-500 for free
accounts)
* If you get `smtplib.SMTPAuthenticationError`, check:
* You’re using the App Password (not your main Gmail password)
* Gmail account allows “less secure” access or you’ve set up the App Password
---
### 📁 Folder Structure Suggestion
```
email_sender/
├── send_emails.py
├── Ashish_Resume.pdf
└── recipients.txt ← optional list of emails
```
---
Let me know if you'd like to:
* Customize each email (like “Hi John”)
* Use HTML formatting for email body
* Send via Outlook or another SMTP server
* Log results into a CSV or file
Happy coding! ✉️