40
loading...
This website collects cookies to deliver better user experience
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# The email addresses and password
sender_address = '[email protected]'
sender_password = 'yourpassword'
gmail_port = 587
receiver_address = '[email protected]'
mail_content = 'Easy peazy lemon squeezy'
message = MIMEMultipart()
message['From'] = sender_address
message['To'] = receiver_address
message['Subject'] = 'Sending email using Python'
message.attach(MIMEText(mail_content, 'plain'))
session = smtplib.SMTP('smtp.gmail.com', gmail_port)
session.starttls() # enable security
session.login(sender_address, sender_password)
text = message.as_string()
session.sendmail(sender_address, receiver_address, text)
session.quit()
print('Email Sent')
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# The email addresses and password
sender_address = '[email protected]'
sender_password = 'yourpassword'
gmail_port = 587
receiver_address = '[email protected]'
mail_content = 'Easy peezy lemon squeezy'
# Setup the MIME
message = MIMEMultipart()
message['From'] = sender_address
message['To'] = receiver_address
message['Subject'] = 'Sending email using Python'
# The body and the attachments for the mail
message.attach(MIMEText(mail_content, 'plain'))
# Create SMTP session for sending the mail
session = smtplib.SMTP('smtp.gmail.com', gmail_port)
session.starttls() # enable security
session.login(sender_address, sender_password)
text = message.as_string()
session.sendmail(sender_address, receiver_address, text)
session.quit()
print('Email Sent')