How to send an email using Python?
To send an email in Python, follow these steps along with the code:
BY Best Interview Question ON 10 Jul 2020
Example
import smtplib
sender = '[email protected]'
receivers = ['[email protected]']
message = """From: From Person <[email protected]>
To: To Person <[email protected]>
Subject: SMTP email test in Python
This is a test email message in Python.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent the email"
except SMTPException:
print "Error display: Python is unable to send an email"