tools.py 文件源码

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

项目:openedoo 作者: openedoo 项目源码 文件源码
def send_email(mail_user, mail_password, mail_recipient, subject, body):
    FROM = mail_user
    TO = mail_recipient if type(mail_recipient) is list else [mail_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 = smtplib.SMTP_SSL("mail.openedoo.org", 465)
        server.ehlo()
        #server.starttls()
        server.login(mail_user, mail_password)
        server.sendmail(FROM, TO, message)
        server.close()
        return 'successfully sent the mail'
    except Exception as e:
        return "failed to send mail"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号