def sendEmail():
'''send email to remind staff to remove unused data.'''
mail_host = "smtp.qq.com"
mail_user = "humaninfo@novogene.com"
mail_pass = "****"
sender = "humaninfo@novogene.com"
title = "【请及时清理磁盘空间】"
msg_txt = 'Hi all:'
message = MIMEText(msg_txt, 'plain', 'utf-8')
message['Subject'] = Header(title, 'utf-8')
message['From'] = Header("***@novogene.com", 'utf-8')
message['To'] = Header("***@novogene.com", 'utf-8')
smtpObj = smtplib.SMTP()
smtpObj.connect(mail_host)
smtpObj.login(mail_user, mail_pass)
smtpObj.sendmail(sender, '***@novogene.com', message.as_string())
print('Email has been sent successfully!')
if __name__=='__main__':
sendEmail()
请教这段代码python3能运行正常发邮件,python2为什么报错?谢谢
本地域名解析有问题哦