selenium+python 调用163邮箱发送邮件失败
#coding=utf-8import smtplib
from email.mime.text import MIMEText
from email.header import Header
#发送邮箱
sender = 'abc@163.com'
#接收邮箱
receiver = 'abc@163.com'
#发送邮件主题
subject = 'python email test'
#发送邮箱服务器
smtpserver = 'smtp.163.com'
#发送邮箱用户/密码
username = 'abc@163.com'
password = '123456'
#中文需参数‘utf-8’,单字节字符不需要
msg = MIMEText('你好!','text','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())
smtp.quit()
执行上面脚本后总是报下面的错误,请大神指导下是咋回事呢??
Traceback (most recent call last):
File "C:\Python27\test0326.py", line 21, in <module>
smtp.login(username, password)
File "C:\Python27\lib\smtplib.py", line 582, in login
self.ehlo_or_helo_if_needed()
File "C:\Python27\lib\smtplib.py", line 545, in ehlo_or_helo_if_needed
raise SMTPHeloError(code, resp)
SMTPHeloError: (500, 'Error: bad syntax') 我遇到过的是因为邮箱账号本身会造成发送失败的情况
可以去邮箱账号里相关设置看一下
页:
[1]