这是运行脚本报错信息
[root@iZ25av9xi4hZ ~]# python send_mail.pyTraceback (most recent call last): File "send_mail.py", line 33, insend_mail(mail_to_list, "系统测试","test") File "send_mail.py", line 23, in send_mail s.login(mail_user,mail_pass) File "/usr/lib64/python2.7/smtplib.py", line 621, in login raise SMTPAuthenticationError(code, resp)smtplib.SMTPAuthenticationError: (535, 'Error: authentication failed')
代码
#coding:utf-8from email.mime.text import MIMETextfrom _ast import Subimport smtplibmail_to_list=["xxxxx@aisino.com","xxxx@aisino.com","xxxx@qq.com"]mail_host="smtp.163.com"mail_user="账号"mail_pass="授权码(是服务商提供163的来自163提供(这个自己填写),qq的由qq提供(这个qq发给你))"mail_postfix="163.com"#发送邮件def send_mail(to_list,sub,content): me = mail_user + "<" +mail_user + "@" + mail_postfix + ">" msg = MIMEText(content,'html','utf-8') 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()) except smtplib.SMTPException as error: print(error) finally: s.close() if __name__ == "__main__": send_mail(mail_to_list, "系统测试","test")