Smtplib Module
Smtplib. SMTP ([host[, port[, local_hostname[, timeout]])
Smtp.connect ([Host[,port]]) remote host
Smtp.login (user.password) remote check
Smtp.sendmail (From_addr,to_addrs,msg[,mail_options,rcpt_options]) for sending mail
SMTP.STATTLS ([Keyfile[,certfile]]) Start TLS secure transfer mode
Smtp.quit () disconnecting the SMTP server
#!/usr/bin/env python
Import Smtplib
Import string
HOST = "Smtp.163.com"
SUBJECT = "Test email from Python"
to = "[Email protected]"
from = "[Email protected]"
Text = "Python rules them all!"
BODY = String.Join ((
"from:%s"% from,
"to:%s"% to,
"subject:%s"% Subject,
"",
Text
), "\ r \ n")
Server = Smtplib. SMTP ()
Server.connect (HOST, "25")
#server. STARTTLS ()
Server.login ("[Email protected]", "XXX")
Server.sendmail (From,[to],body)
Server.quit ()
This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1582759
Python smtplib module operation and maintenance automation