concordsvr.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:device-concord4 作者: csdozier 项目源码 文件源码
def send_email(user, pwd, recipient, subject, body):
    import smtplib

    gmail_user = user
    gmail_pwd = pwd
    FROM = user
    TO = recipient if type(recipient) is list else [recipient]
    SUBJECT = subject
    TEXT = body

    # Prepare actual message
    message = """From: %s\nTo: %s\nSubject: %s\n\n%s
    """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
    try:
        server_ssl = smtplib.SMTP_SSL("smtp.gmail.com", 465)
        server_ssl.ehlo()
        server_ssl.login(gmail_user, gmail_pwd)
        server_ssl.sendmail(FROM, TO, message)
        server_ssl.close()
        log.info("E-mail notification sent")
    except Exception, ex:
        log.error("E-mail notification failed to send: %s" % str(ex))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号