zoukankan      html  css  js  c++  java
  • Python发送邮件

    发送邮件的Demo:

    使用smtp服务必须在相应邮箱服务器设置中开启SMTP服务,并且生成授权码

    例如QQ:

    import smtplib
    from email.mime.text import MIMEText
    
    #第三方SMTP服务
    mail_host = "smtp.qq.com"
    mail_user = "wsyjlly@foxmail.com"
    mail_pass = "授权码"
    
    sender = "wsyjlly@foxmail.com"
    receiver = "wsyjlly@foxmail.com"
    
    message = MIMEText("你好,世界!")
    message["From"] = sender
    message["To"] = receiver
    message["Subject"] = "一起嗨吧!"
    
    def send_email():
        try:
            server = smtplib.SMTP()
            server.connect(mail_host)
            server.login(mail_user,mail_pass)
            server.sendmail(sender,receiver,message.as_string())
            server.close()
            print("邮件发送成功!")
        except Exception as e:
            print("邮件发送失败!",e)
    
    if __name__ == '__main__':
        send_email()
  • 相关阅读:
    从服务器角度分析RPG游戏——NPC的AI
    羽翼特效设计
    坐骑特效设计(二)
    坐骑特效设计
    Unity AssetBundle打包资源工具
    有趣的进度条
    原生与组件
    bower
    yeoman
    grunt+bower+yo
  • 原文地址:https://www.cnblogs.com/wsyjlly/p/10403615.html
Copyright © 2011-2022 走看看