Sending mail from Python using SMTP Module. Python provides smtplib module, which defines an SMTP client session object that can be used to send mails to any Internet machine with an SMTP or ESMTP listener daemon.
This repository contains a Python script for sending emails using the smtplib
module. The script establishes a connection to an SMTP server, logs in with the provided credentials, and sends an email to the specified recipient.
Before running the script, ensure you have the following:
- Python installed on your machine.
- An email account with an SMTP server (e.g., Gmail) that allows you to send emails programmatically.
-
Clone this repository to your local machine:
git clone https://github.com/Kunal-kawate/Python_SMTP_Source_Code.git
-
Navigate to the project directory:
cd Python_SMTP_Source_Code
-
Open the
SMTP.py
file and update the following variables with your email and server information:HOST = "smtp.gmail.com" PORT = 587 FROM_EMAIL = "Sender_Mail_Here" PASSWORD = 'Password'
Run the script using the following command:
python SMTP.py
The script will prompt you to enter the recipient's email address, the email subject, and the message. After providing the necessary information, the script will attempt to send the email and display status information for each step of the process.
Note: If you are using Gmail, make sure to enable "Less secure app access" in your account settings or use an "App Password" for the script to log in successfully.
This script is provided as-is and may require adjustments based on your specific email server and security settings. Use it responsibly and ensure compliance with the terms of service of your email provider. Made with Love | KunyaThing