标签:发送 UI 内容 mime add utils plain end else
def email(): import smtplib from email.mime.text import MIMEText from email.utils import formataddr
ret = True
try:
msg = MIMEText(‘邮件内容‘,‘plain‘,‘utf-8‘) msg[‘From‘] = formataddr([‘zhou‘,‘发件邮箱帐号‘]) msg[‘To‘] = formataddr([‘zzm‘,‘8400033‘]) msg[‘Subject‘] = ‘主题‘ server = smtplib.SMTP(‘smtp.163.com‘,25) server.login(‘发件邮箱帐号‘,‘发件邮箱密码‘) server.sendmail(‘发件邮箱帐号‘,[‘收件邮箱帐号‘],msg.as_string()) server.quit()
except:
ret = False
return ret email()
if ret:
print(‘发送成功‘)
else:
print(‘发送失败‘)
标签:发送 UI 内容 mime add utils plain end else
原文地址:http://www.cnblogs.com/xone/p/6786364.html