Http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html
http://blog.csdn.net/imzoer/article/details/8674263
#-*-coding:utf-8-*- #===============================================================================# import Smtplib and mimetext#=============================================================================== fromemail.mime.text Import Mimetextimport smtplib#===============================================================================# who to send to 2 people here #===============================================================================mailto_list=["[email protected]","[email protected]"]#===============================================================================# Set the server, user name, password, and suffix of the mailbox #===============================================================================Mail_host="smtp.qq.com"Mail_user="naughty610"Mail_pass="Here is your password"Mail_postfix="qq.com"#===============================================================================# Send mail #===============================================================================def send_mail (to_list,sub,content):" "To_list: To whom sub: topic Content: Contents Send_mail ("[email protected]","Sub","content") " "me=mail_user+"<"+mail_user+"@"+mail_postfix+">"msg=mimetext (content) msg['Subject'] =Sub msg[' from'] =Me msg[' to'] =";". Join (to_list)Try: S=Smtplib. SMTP () s.connect (mail_host) s.login (Mail_user,mail_pass) S.sendmail (Me, To_list, msg.as_string ()) S.close ()returnTrue except Exception, E:print str (e)returnFalseif__name__ = ='__main__': ifSend_mail (Mailto_list,"Here is subject","Here is content"): Print"sent successfully" Else: Print"Send failed"
Python e-mail