0% found this document useful (0 votes)
3 views2 pages

Last

This document provides a Python script for sending individual emails with attachments to multiple recipients using a Gmail account and App Password authentication. It includes prerequisites such as creating an App Password and installing the required library, along with detailed code for constructing and sending the emails. The script sends emails sequentially and prints success or failure messages for each recipient.

Uploaded by

ashishsingh.web3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Last

This document provides a Python script for sending individual emails with attachments to multiple recipients using a Gmail account and App Password authentication. It includes prerequisites such as creating an App Password and installing the required library, along with detailed code for constructing and sending the emails. The script sends emails sequentially and prints success or failure messages for each recipient.

Uploaded by

ashishsingh.web3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Here’s a complete **Python script** to send an email with an attachment to

**multiple recipients**, sending **one email at a time** to each, using a Gmail


account and **App Password** authentication:

---

### ✅ Prerequisites:

* [Create an App Password from Gmail](https://myaccount.google.com/apppasswords)


(if using 2FA).
* Install required library (if not already):

```bash
pip install secure-smtplib
```

---

### ✅ Python Script to Send Individual Emails

```python
import smtplib
from email.message import EmailMessage
import os

# Email account credentials


EMAIL_ADDRESS = "[email protected]"
EMAIL_PASSWORD = "your_app_password" # 16-character app password from Gmail

# List of recipients
recipients = [
"[email protected]",
"[email protected]",
"[email protected]",
# Add more...
]

# Email content
subject = "Exploring Opportunities – Backend Software Engineer"
body = """
I wanted to reach out to discuss potentially working together.
I’m a Backend software engineer working in LendingKart and currently seeking new
opportunities.
PFA my resume for your reference
LinkedIn: https://www.linkedin.com/in/ashish-singh-39127b288

Thanks and Regards


Ashish Singh
"""

# Path to resume
resume_file = "Ashish_Resume.pdf" # Change to your resume file path

# Send email to each recipient one by one


for recipient in recipients:
try:
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = EMAIL_ADDRESS
msg['To'] = recipient
msg.set_content(body)

# Add attachment
with open(resume_file, 'rb') as f:
file_data = f.read()
file_name = os.path.basename(resume_file)
msg.add_attachment(file_data, maintype='application', subtype='pdf',
filename=file_name)

# Send email
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
smtp.send_message(msg)

print(f"Email sent to {recipient}")

except Exception as e:
print(f"Failed to send email to {recipient}: {e}")
```

---

### ✅ Notes:

* Emails are sent **sequentially**.


* The script will **print success/failure** for each recipient.
* You can expand the recipients list via a CSV or a text file if needed.

Let me know if you want a version that reads recipients from a file.

You might also like