BeginMan
V2EX  ›  Flask

flask-mail 使用 QQ 企业邮箱异常?

  •  
  •   BeginMan · Dec 9, 2015 · 6729 views
    This topic created in 3808 days ago, the information mentioned may be changed or developed.

    flask 版本和 flask-mail 版本都是最新的, 配置如下:

    MAIL_SENDER = "[email protected]"
    MAIL_SERVER = 'smtp.exmail.qq.com'
    MAIL_USE_TLS = False
    MAIL_USE_SSL = True
    MAIL_PORT = 465
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or '[email protected]'
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    
    ....
    
    send_email("[email protected]", "test")
    

    异常提示:

    SMTPAuthenticationError: (521, 'Error: Invalid domain name, please use smtp.qq.com. More information at http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=371')
    

    改成:smtp.qq.com后,也报错了:

    SMTPSenderRefused: (501, 'mail from address must be same as authorization user')
    

    如果不用 QQ 企业邮箱,改成自己的 QQ 邮箱则没有问题。

    ps.已开启 POP/SMTP 服务、 MAP/SMTP 服务

    求指教!

    4 replies    2015-12-11 14:51:53 +08:00
    liuxu
        1
    liuxu  
       Dec 9, 2015
    mail from address must be same as authorization user

    MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or '[email protected]'


    MAIL_USERNAME 有问题?
    $echo $MAIL_USERNAME 看看
    BeginMan
        2
    BeginMan  
    OP
       Dec 9, 2015
    cao, 太粗心了,忘记更改环境变量了。。。。
    MrEggNoodle
        3
    MrEggNoodle  
       Dec 9, 2015
    @BeginMan 看过你的 Blog 好几次,不是搞 Django 的!怎么跑去 flask 了。
    BeginMan
        4
    BeginMan  
    OP
       Dec 11, 2015
    @MrEggNoodle 一年多没搞 Django ,一直是 tornado,flask.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3610 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 99ms · UTC 10:39 · PVG 18:39 · LAX 03:39 · JFK 06:39
    ♥ Do have faith in what you're doing.