python - Flask_mail 我得到两个不同的 FROM 行邮件标题

标签 python email smtp flask-mail

我正在使用flask_mail,配置为使用gmail smtp 服务器。它发送邮件很好,除了所有邮件看起来都来自 gmail smtp 用户名,而不是来 self 在 mail.send_message(...) 命令的“sender”参数中设置的内容。当我查看生成电子邮件的来源时,我看到 2 个不同的发件人地址。我如何更改它以显示我想要的“来自”?

    mail.send_message(subject='subject line',
                      sender='<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="670a1e380115080a38020a060e0b27000a060e0b4904080a" rel="noreferrer noopener nofollow">[email protected]</a>', 
                      recipients=['<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="127f6b4d667d4d777f737b7e52757f737b7e3c717d7f" rel="noreferrer noopener nofollow">[email protected]</a>'],
                      bcc=['<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fe9c9d9da19b939f9792be99939f9792d09d9193" rel="noreferrer noopener nofollow">[email protected]</a>'],
                      reply_to='<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="264b5f794054494b79434b474f4a66414b474f4a0845494b" rel="noreferrer noopener nofollow">[email protected]</a>')

标题的剪裁看起来像......

...
From: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="137e6a4c607e67634c666076614c7d727e7653747e727a7f3d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>
X-Google-Original-From: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24495d7b42564b497b4149454d48644349454d480a474b49" rel="noreferrer noopener nofollow">[email protected]</a>
Content-Type: multipart/mixed; boundary="===============8405132704319078372=="
MIME-Version: 1.0
...

最佳答案

TLDR:gmail smtp 服务器正在防止电子邮件欺骗。

参见:https://github.com/gophish/gophish/issues/1311

修复:

登录您的[email protected] Gmail 帐户并将发送电子邮件设置为 [email protected]首先是那里。一旦您的帐户被允许并经过身份验证,可以像您的其他帐户一样发送电子邮件,您的 header 应该停止被重写。

参见:https://support.google.com/mail/answer/22370?hl=en

关于python - Flask_mail 我得到两个不同的 FROM 行邮件标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60481895/

相关文章:

email - Amazon LEX native 电子邮件槽类型无法识别以 4 位数结尾的电子邮件

c# - SmtpClient 可扩展性问题(仅运行两个请求)

python - 在 Django 中上传和提交 csv 文件时,“str”不支持缓冲区接口(interface)

python - 如何使用 "select_for_update()"在 Django 中获取对象?

php - 从数据库获取数据并与用户输入进行比较

c# - 如何在 MVC3 应用程序中构建用于发送的 HTML 消息?

python - Model() 获得参数 'nr_class' 的多个值 - SpaCy 多分类模型(BERT 集成)

python - 在 GitHub Actions CI 中运行 testcontainers-python

java - 处理电子邮件服务器时如何处理代理?

java - SMTP/POP3 通过代理 System.getProperties() 与 new Properties()?