V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
BeginMan
V2EX  ›  Flask

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

  •  
  •   BeginMan · 2015-12-09 14:26:10 +08:00 · 5785 次点击
    这是一个创建于 3062 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 条回复    2015-12-11 14:51:53 +08:00
    liuxu
        1
    liuxu  
       2015-12-09 14:37:30 +08:00
    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
       2015-12-09 14:48:31 +08:00
    cao, 太粗心了,忘记更改环境变量了。。。。
    MrEggNoodle
        3
    MrEggNoodle  
       2015-12-09 20:38:14 +08:00
    @BeginMan 看过你的 Blog 好几次,不是搞 Django 的!怎么跑去 flask 了。
    BeginMan
        4
    BeginMan  
    OP
       2015-12-11 14:51:53 +08:00
    @MrEggNoodle 一年多没搞 Django ,一直是 tornado,flask.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2896 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:15 · PVG 15:15 · LAX 00:15 · JFK 03:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.