• QQ邮箱/微信邮箱发送邮件


    import yamail
    user = 'XX@qq.cn'#我自己的邮箱
    passwold = 'xbaT82SpnwyaHFdn'  #生成授权码(登录邮箱,设置pop3/smtp 开启,点击生成授权码)
    host ='smtp.qq.cn'
    mail = yamail.SMTP(host=host,user=user,password=passwold)
    mail.send(
        to=['xxx@qq.cn'],
        cc=[],
        subject='测试一下',
        contents='发送消息'
    )##to-接收人邮箱,cc-抄送人邮箱,subect-邮件主题,contents-邮件内容,attachments-邮件附件,可通过列表传多个附件 ,接收人,抄送人
    
    mail.close()
    import smtplib
    from email.mime.text import MIMEText
    from email.header import Header
    import poplib
    import base64,re
    from email.parser import Parser
    
    def mail(content):
        mail_host = "smtp.exmail.qq.com"  # 设置服务器
        mail_user = "song@xxx.cn"  # 用户名
        mail_pass = "xbaT82SpnwyaHFdn"  # 口令
    
        sender = 'song@xxx.cn'
        receivers = ['lei@sceneconsole.cn']  # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
    
        message = MIMEText(content, 'plain', 'utf-8')
        message['From'] = Header("song@xxx.cn", 'utf-8')
        message['To'] = Header("lei@xxx.com", 'utf-8')
    
        subject = "11.05-日报"
    
    
        message['Subject'] = Header(subject, 'utf-8')
    
        try:
            smtpObj = smtplib.SMTP()
            smtpObj.connect(mail_host, 25)  # 25 为 SMTP 端口号
            smtpObj.login(mail_user, mail_pass)
            smtpObj.sendmail(sender, receivers, message.as_string())
            print("邮件发送成功")
        except smtplib.SMTPException:
            print("Error: 无法发送邮件")
    mail('早上好,今日计划如下:
     1、测试大V后台
     ')
  • 相关阅读:
    面试题_day0212
    面试题_day0211
    猫眼的数字解密
    缺口验证码
    mysql替换字段里面的内容
    mysql重复id删除
    追踪你的女朋友。
    淘宝登录验证
    jadx-gui-1.0.0.jar怎么运行?
    Python实现一个进度条
  • 原文地址:https://www.cnblogs.com/xxxxyanyan/p/14109134.html
Copyright © 2020-2023  润新知