Sending Email Using SMTP : SMTP : Network PYTHON TUTORIALS


PYTHON TUTORIALS » Network » SMTP »

 

Sending Email Using SMTP


import smtplib
import time

From = "name@from.org"
To = ["name@to.com"]
Date = time.ctime(time.time())
Subject = "New message."
Text = "Message Text"
#Format mail message
mMessage = ('From: %snTo: %snDate: 
            %snSubject: %sn%sn' %
            (From, To, Date, Subject, Text))

print 'Connecting to Server'
s = smtplib.SMTP('mail.sfcn.org')

rCode = s.sendmail(From, To, mMessage)
s.quit()

if rCode:
    print 'Error Sending Message'
else:
    print 'Message Sent Successfully'



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Network
» SMTP