码迷,mamicode.com
首页 > 其他好文 > 详细

11111

时间:2017-11-26 16:47:19      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:.net   for   from   dma   span   /usr   except   失败   print   

 
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/10/23 0023 14:24
# @Author  : ming
def email(s, r, t):
    ret = True
    try:
        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr

        msg = MIMEText(s, "Plain", "utf-8")
        msg["from"] = formataddr(["杨永明", "18844123268@163.com"])
        msg["To"] = formataddr(["TO", "bjyangyongming@corp.netease.com"])
        msg["Subject"] = t

        server = smtplib.SMTP("smtp.163.com", 25)
        server.login("18844123268@163.com", "ming102318")
        server.sendmail("18844123268@163.com", [r], msg.as_string())
        server.quit()
    except:
        ret = False
    return ret
ret = email(t = "我是主题", r = "bjyangyongming@corp.netease.com", s = "我是内容")
if ret == True:
    print "邮件发送成功"
else:
    print "邮件发送失败"

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/10/23 0023 14:24
# @Author  : ming
def email(s, r, t):
    ret = True
    try:
        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr

        msg = MIMEText(s, "Plain", "utf-8")
        msg["from"] = formataddr(["杨永明", "18844123268@163.com"])
        msg["To"] = formataddr(["TO", "bjyangyongming@corp.netease.com"])
        msg["Subject"] = t

        server = smtplib.SMTP("smtp.163.com", 25)
        server.login("18844123268@163.com", "ming102318")
        server.sendmail("18844123268@163.com", [r], msg.as_string())
        server.quit()
    except:
        ret = False
    return ret
ret = email(t = "我是主题", r = "bjyangyongming@corp.netease.com", s = "我是内容")
if ret == True:
    print "邮件发送成功"
else:
    print "邮件发送失败"

 

11111

标签:.net   for   from   dma   span   /usr   except   失败   print   

原文地址:http://www.cnblogs.com/ming5218/p/7899201.html

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