python2.7发送邮件失败之——SMTPAuthenticationError问题

使用python2.7发送邮件,代码如下:

from  email.header import Header
from email.mime.text import MIMEText
import smtplib
#发送邮箱
sender='yq_test@126.com'
password='123456'
#接受邮箱
receiver='41618174@qq.com'

smtpserver='smtp.126.com'

subject='python email test'
msg=MIMEText('下雨了,大家关好窗户','plain','utf-8')
msg['Subject']=Header(subject,'utf-8')
msg['From']=sender
msg['to']=receiver
try:
smtp=smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(sender,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()
print "邮件发送成功"
except smtplib.SMTPException:
print "Error:无法发邮件"
运行时提示:SMTPAuthenticationErro错误,解决办法:
1、邮箱服务器是否正确:smtp.163.com、smtp.qq.com、smtp.126.com等
2、SMTPserver是SMTP邮件服务器SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,故发送邮箱需要开启SMTP服务,邮箱服务器才能认证成功。一般在邮箱网页版本的设置界面:

3、如果以上设置成功还提示认证错误,那检查你发送邮箱的用户名和密码是否设置正确。

各位看官,看完后不要忘了为我乐于分享的精神点个赞哦,您的支持是我不断进步动力,谢谢

 

 

转载于:https://www.cnblogs.com/Ladylittleleaf/p/9719696.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值