demo_smtp.py 文件源码

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

项目:BAPythonDemo 作者: boai 项目源码 文件源码
def ba_smtp_sendEmail(email_title, email_content, email_type, email_sender, email_receiver, email_host, email_user, email_pwd):

    # ??, ??, ??
    message = MIMEText(email_content, email_type, 'utf-8')
    message['From'] = '{}'.format(email_sender)
    message['To'] = ','.join(email_receiver)
    message['Subject'] = email_title

    try:
        # ??SSL??, ?????465
        smtpObj = smtplib.SMTP_SSL(email_host, 465)
        # ????
        smtpObj.login(email_user, email_pwd)
        # ??
        smtpObj.sendmail(email_sender, email_receiver, message.as_string())
        print('??????!')
    except smtplib.SMTPException as e:
        print("Error: ??????")
        print(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号