标签:mat psd .com string format str from utils email
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
def mail():
ret = 123
try:
msg = MIMEText(‘the mail contents‘, ‘plain‘, ‘utf-8‘)
msg[‘From‘] = formataddr([‘NameA‘, ‘Email_addr_S‘])
msg[‘To‘] = formataddr([‘nameB‘, ‘Email_addr_R‘])
msg[‘Subject‘] = "Subject"
server = smtplib.SMTP(‘smtp.126.com‘, 25)
server.login(‘Email_addr_S‘,‘PSD‘)
server.sendmail(‘Email_addr_S‘,[‘Email_addr_R‘,],msg.as_string())
server.quit
except Exception:
ret = 456
return ret
ret = mail()
print(ret)
标签:mat psd .com string format str from utils email
原文地址:http://www.cnblogs.com/tlfox2006/p/7229198.html