Sending Email Using SMTP : SMTP « Network « Python Tutorial






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: %s\nTo: %s\nDate: \
            %s\nSubject: %s\n%s\n' %
            (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'








21.11.SMTP
21.11.1.Sending Email Using SMTP
21.11.2.Retrieving Email from a POP3 Server
21.11.3.SMTP and POP3 Example
21.11.4.SMTP transmission with authentication
21.11.5.Basic SMTP transmission
21.11.6.SMTP transmission with debugging
21.11.7.POP mailbox downloader
21.11.8.POP mailbox scanning
21.11.9.POP connection and authentication
21.11.10.POP connection and authentication with APOP