
经过初步的分析,应该是可以实现登录的,因为我尝试注释发送文字只登录没有错误提示
但是加上要发送的内容就提示出错了,源代码如下
代码: 全选
#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = 'xxx@163.com'
receiver = 'xxx@qq.com'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = 'xxx'
password = 'xxx'
msg = MIMEText('Hello','text')#中文需参数‘utf-8’,单字节字符不需要
msg['Subject'] = Header(subject)
smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()