码迷,mamicode.com
首页 > 编程语言 > 详细

python2.4 发送邮件

时间:2015-03-04 11:13:58      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:python2.4 sendmail

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‘)

本文出自 “自动化rolin” 博客,请务必保留此出处http://luoguoling.blog.51cto.com/1568501/1617114

python2.4 发送邮件

标签:python2.4 sendmail

原文地址:http://luoguoling.blog.51cto.com/1568501/1617114

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!