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

python 发送邮件,未完

时间:2015-10-22 00:10:43      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

def send_mail():
        try:
                print "send mail..."
                # handle = smtplib.SMTP(‘smtp.163.com‘, 25)
                # handle.login(‘gjp_1988@163.com‘,‘5595awd1226‘)
                # msg = "To: gjp_1988@qq.com\r\nFrom: gjp_1988@163.com\r\nSubject: startpc \r\n\r\nstart\r\n"
                # handle.sendmail(‘gjp_1988@163.com‘,‘gjp_1988@qq.com‘, msg)
                # handle.close()
                #如上方法无法发送mail,原因不详。

                smtp = smtplib.SMTP()
                smtp.connect(‘smtp.163.com‘)
                smtp.login(‘gjp_1988‘,‘5595awd1226‘)
                msg = "To: gjp_1988@qq.com\r\nFrom: gjp_1988@163.com\r\nSubject: startpc \r\n\r\nstart\r\n"
                smtp.sendmail(‘gjp_1988@163.com‘,‘gjp_1988@qq.com‘,msg)
                smtp.close()
                #如上方法发送有时候接收不到,感觉很不稳定。

                print "send mail end"
                return 1
        except:
                return 0

  

python 发送邮件,未完

标签:

原文地址:http://www.cnblogs.com/hester/p/4899351.html

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