1.

How to send an email using Python?

Answer»

To send an EMAIL in PYTHON, follow these STEPS along with the code:

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"



Discussion

No Comment Found