Proginst ufal mail
You're looking for a program to send an email using Python!
There are several ways to send an email using Python, but one popular library is smtplib
. Here's a simple example to get you started:
Install the smtplib
library
You can install smtplib
using pip:
pip install smtplib
Send an email using smtplib
Here's an example code snippet:
import smtplib
from email.mime.text import MIMEText
# Define the email settings
SMTP_SERVER = "smtp.gmail.com"
SMTP_PORT = 587
FROM_EMAIL = "[email protected]"
PASSWORD = "your_password"
# Define the email message
SUBJECT = "Test Email"
BODY = "This is a test email sent using Python!"
# Create a text message
msg = MIMEText(BODY)
msg['Subject'] = SUBJECT
msg['From'] = FROM_EMAIL
msg['To'] = "[email protected]"
# Connect to the SMTP server
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
server.starttls()
server.login(FROM_EMAIL, PASSWORD)
# Send the email
server.sendmail(FROM_EMAIL, "[email protected]", msg.as_string())
# Close the SMTP connection
server.quit()
Note:
- Make sure to replace
[email protected]
andyour_password
with your actual Gmail credentials. - You may need to enable "Less secure app access" in your Google Account settings to use
smtplib
with Gmail. - This is just a basic example, and you may want to add more features like attachments, HTML formatting, or error handling.