利用python模块发送mail错误

大培哥 发布于 2015/11/25 17:01
阅读 1K+
收藏 0

程序如下;

import smtplib
from email.mime.text import MIMEText
from email.header import Header

sender = '省略'
receiver = '同上'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '省略'
password = '省略'

msg = MIMEText('你好','text','utf-8')#中文需参数‘utf-8',单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())

报错如下:

Traceback (most recent call last):

  File "sendemail_1.py", line 19, in <module>
    smtp.login(username, password)
  File "/usr/lib/python2.7/smtplib.py", line 615, in login
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (550, 'User has no permission')

我确认自己的账号密码输入正确,哪位兄台来指导一下?
加载中
返回顶部
顶部