Use Python SMTP to send mail

smtplib Import 
from email.mime.text Import MimeText

# server
SMPTserver = "smtp.163.com"
# Send e-mail address (your email address)
SENDER = "[email protected]"
# authorization code (not the same as the login password )
password = "XXXXXXXXXXX"
text # send
the message = "ZHF iS a Good man"
# into the message text
msg = MimeText (the message)
msg [ "Subject"] = "ZHF"
msg [ "the From"] = SENDER
# smtp server connection
MailServer = smtplib.SMTP (SMPTserver, 25)
# login
mailServer.login (SENDER, password)
# sending mail
mailServer.sendmail (SENDER, [ "[email protected]"], msg.as_string ())
MailServer. quit ()

Guess you like

Origin www.cnblogs.com/zhf123/p/11525005.html