• python 163 email 554


    • 报554的原因主题或内容中没有中文, 仅此而已
    • setting.py
    MAIL_USER = 'XXX@163.com'
    MAIL_PASS = 'XXX'    #不是邮箱登陆密码是开启smtp时的密码
    MAIL_SENDER = 'XXX'
    MAIL_HOST = 'smtp.163.com'
    MAIL_PORT = 25
    
    
    • sender.py
    import smtplib
    from email.mime.text import MIMEText
    from email.header import Header
    
    from setting import MAIL_SENDER, MAIL_HOST, MAIL_USER, MAIL_PASS, MAIL_PORT
    
    
    def send_email(receivers, body_content, subject):
        body_content = '内容:
    {}'.format(body_content)
        subject = '主题:{}'.format(subject)
        message = MIMEText(body_content, 'plain', 'utf-8')
        message['From'] = MAIL_SENDER
        message['To'] = ','.join(receivers)
        message['Subject'] = Header(subject, 'utf-8')
        smtp_obj = smtplib.SMTP()
        smtp_obj.connect(MAIL_HOST, MAIL_PORT)
        smtp_obj.set_debuglevel(1)
        smtp_obj.login(MAIL_USER, MAIL_PASS)
        smtp_obj.sendmail(MAIL_SENDER, receivers, message.as_string())
        smtp_obj.quit()send_email(receivers, body_content, subject):
    #例
    if __name__ == '__main__':
        send_email(['XXX1@X.com', 'XXX2@X.com', 'XXX3@X.com'], 'x', 'y')
    
    
  • 相关阅读:
    19.将写好的输出到本地 文件格式:Step
    18.对Topo进行打孔
    17.球体
    16.圆柱
    15.绘制圆锥
    14.Chamfer把正方体所有的边倒角
    13.绘制一个方体
    ①②坐标点
    esp8266接线
    IP解析
  • 原文地址:https://www.cnblogs.com/edhg/p/11313625.html
Copyright © 2020-2023  润新知