Send emails with attachments using Python's smtplib
and the email
library. This simple script demonstrates how to send emails with attachments programmatically.
This PythonMailWithAttachments project allows you to send emails with attachments using Python. It uses the smtplib
library to establish an SMTP connection and the email
library to create and format the email message. This script is particularly useful for sending automated emails with attachments.
- Attachment Support: Attach files to your emails with ease.
- Easy Configuration: Set up sender's email, password, receiver's email, and other details in the script.
- Customizable Message: Personalize the email body as needed.
Ensure you have Python installed on your system.
-
Clone the GitHub repository:
git clone https://github.com/codeterrayt/PythonMailWithAttachments.git cd PythonMailWithAttachments
-
Install the required libraries:
pip install secure-smtplib
-
Open
main.py
in a text editor. -
Update the following variables with your email details:
fromaddr
: Sender's email address.password
: Sender's email password.toaddr
: Receiver's email address.subject
: Email subject.body
: Email body text.filename
: Name of the file to be attached (e.g., "home.png").
-
Save the changes.
-
Run the script:
python main.py
-
The script will prompt you for your email password and send the email with the attached file.
Feel free to explore and modify the code to suit your specific needs. You can customize the email subject, body, and attachment details as per your requirements.
This project uses the smtplib
and email
libraries for sending emails with attachments. Explore the Python smtplib
Documentation and Python email
Documentation for more information.
💌 Happy Emailing! 🚀