Calling third-party mailboxes using Python bulk mail third-party mail needs to set the authorization code here is 163 mailbox, the map cannot be uploaded. Set ===> mailbox security Settings ===> client authorization Password Code section: #!/usr/bin/env python#__*__coding:utf-8__*__import smtplibfrom email.mime.text import MIMEText as mimetextfrom email.mime.multipart import mimemultipart# Outgoing mail server address mail_host = ' smtp.163.com ' #发件邮箱地址sender_user = ' [email protected] ' #mail_pass = ' xxxxx ' #登录密码 # Email Authorization code, not login password sender_pass = ' xxxx ' # Email address receivers = [' [email protected] ', ' [email protected] '] #邮件内容message = Mimetext (' python mail test sent ', ' plain ', ' utf-8 ') #发送邮箱地址message [' From '] = sender_user# send an error when sending a message message[' To '] does not support lists, use the Join function to compound the address string message[' to '] = ",". Join (receivers) #邮件主题subject = ' Python SMTP Mail test ' message[' Subject '] = subject# try:# smtpobj = smtplib. SMTP () # smtpobj.connect (mail_host,25) # &nbSp; smtpobj.login (Mail_user,mail_pass) # smtpobj.sendmail (Sender,receivers, message) # print ' mail sent successfully ' # except:# print "Mail send Failed" smtpobj = smtplib. SMTP () smtpobj.connect (mail_host,25) smtpobj.login (sender_user,sender_pass) smtpobj.sendmail (Sender_user, Receivers,message.as_string ()) Smtpobj.close ()
This article is from the "LINUX" blog, so be sure to keep this source http://wangpengtai.blog.51cto.com/3882831/1950887
Python Send mail