import smtplib
#from email.mime.text import MIMEText
from email.MIMEText import MIMEText
def send_email(content):
sender = "lgl15984@163.com"
receiver = [xxx@qq.com]
host = '220.181.12.16'
port = 465
msg = MIMEText(content)
msg['From'] = "lgl15984@163.com"
msg['To'] = "xxxx@qq.com"
msg['Subject'] = "backup check"
try:
smtp = smtplib.SMTP()
smtp.connect('220.181.12.16:25')
# smtp.ehlo()
# smtp.starttls()
# smtp.ehlo()
# smtp = smtplib.SMTP_SSL(host, port)
smtp.login(sender, 'xxxx')
smtp.sendmail(sender, receiver, msg.as_string())
# getlog().info("send email success")
except Exception, e:
# get_log().error(e)
print 'email fail'
print e
pass
send_email('aaa')
本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/1617114