zoukankan      html  css  js  c++  java
  • python使用yagmail发送邮件

    1. 下载依赖

    pip install yagmail

    2. 获取授权码

    授权码获取方式查看链接:https://www.cnblogs.com/lxz123/p/14962000.html注:以前写的这种发送邮件的方式,在往公司邮箱(阿里邮箱)发送邮件的时候,显示发送成功,但是邮件收不到,后面改用了现在写到的这种方式,可以推送,所以在这里记录一下

    3.发送邮件

    import yagmail
        body = "Hello there from Yagmail"  # 邮件正文
        filename = "./sendEmail.py"  # 要发送的附件
        mail_name = "**********@qq.com"  # 发送人邮箱地址
        mail_password = "******"  # 注意:这里不是密码,而应该填写授权码!
        yag = yagmail.SMTP(
            user='******@qq.com',  # 要发送邮件的邮箱,可以自己发送给自己
            password='******',  # 授权码
            host='smtp.qq.com')
        yag.send(
            to=to,
            subject="Yagmail test with attachment",  # 邮件标题
            contents=body,
            attachments=filename)
  • 相关阅读:
    走迷宫(三):在XX限制条件下,是否走得出。
    ELMo
    BERT
    ARNOR 远程关系监督抽取
    谷歌T5
    seq2seq
    Attention Is All You Need(Transformer)
    attention的实现
    RNN
    test
  • 原文地址:https://www.cnblogs.com/lxz123/p/15801529.html
Copyright © 2011-2022 走看看