import smtplib
from email.mime.text import MIMEText
mailto_list=["xxx@163.com"]
mail_host="smtp.163.com"
mail_user="xxxx@163.com"
mail_pass="xxx"
def send_mail(to_list,sub,content):
me="hello"
msg = MIMEText(content,_subtype='html',_charset='gb2312')
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()
return True
except Exception, e:
print str(e)
return False
if __name__ == '__main__':
if send_mail(mailto_list,"hello","<a href='http://www.cnblogs.com/'>hello</a>"):
print "success"
else:
print "fail"
python 发邮件 535, 'Error: authentication failed'
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
7条回答
- frank_20080215 2015-06-09 15:05关注
认证出了问题。SMTP有两种,一种强制要求验证,称为ESMTP。还有一种不要求验证,早的版本。
确认一下该SMTP是否要求验证?本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报