|
执行报错:
F:\flask>python2 send4.py
Traceback (most recent call last):
File "send4.py", line 16, in <module>
smtp.login(email_user,email_pwd)
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)
smtplib.SMTPHeloError: (500, 'Error: bad syntax')
代码:
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
email_host = 'smtp.126.com'
email_user = 'xxxxxx@126.com'
email_pwd = '******'
maillist = 'xxxxxx@qq.com'
me = email_user
msg = MIMEText('THIS IS TEST')
msg['Subject'] = 'python'
msg['From'] = me
msg['To'] =maillist
smtp = smtplib.SMTP(email_host,port=25)
smtp.login(email_user,email_pwd)
smtp.sendmail(me,maillist,msg.as_string())
smtp.quit()
print 'emil send success'
|
|