相关资料:

http://www.cnblogs.com/xiaowuyi

 

实例代码:

 1 import smtplib  
 2 from email.mime.text import MIMEText  
 3 mailto_list=["zhu@163.com.cn"] 
 4 mail_host=r"exchange.163.com.cn"  #设置服务器
 5 mail_user="zhu"    #用户名
 6 mail_pass="123456789"   #口令 
 7 mail_postfix="163.com.cn"  #发件箱的后缀
 8   
 9 def send_mail(to_list,sub,content):  
10     me="<"+mail_user+"@"+mail_postfix+">"  
11     msg = MIMEText(content,_subtype='plain',_charset='gb2312')  
12     msg['Subject'] = sub  
13     msg['From'] = me  
14     msg['To'] = ";".join(to_list)  
15     try:  
16         server = smtplib.SMTP()  
17         server.connect(mail_host)  
18         server.login(mail_user,mail_pass)  
19         server.sendmail(me, to_list, msg.as_string())  
20         server.close()  
21         return True  
22     except Exception, e:  
23         print str(e)  
24         return False  
25 if __name__ == '__main__':  
26     if send_mail(mailto_list,"hello","hello world!"):  
27         print "发送成功"  
28     else:  
29         print "发送失败"

 

相关文章:

  • 2022-03-09
  • 2023-03-07
  • 2021-09-21
  • 2021-07-03
  • 2021-09-16
猜你喜欢
  • 2021-07-09
  • 2021-10-22
  • 2022-12-23
  • 2021-09-11
  • 2021-05-29
  • 2022-12-23
相关资源
相似解决方案