pfaffman
(Jay Pfaffman)
2024 年4 月 29 日 13:42
1
我注意到许多网站抱怨没有定义 Mailgun API 密钥,但(至少大多数)这些网站通过邮件接收器容器接收回复,并且它会处理这些退信,因此不需要 API 密钥(以及 Mailgun 上的相应 webhook)。看起来规范(以及代码)中的逻辑是颠倒的:
missing_mailgun_api_key_spec
显示这个:
context "when using Mailgun without an API key" do
let(:replies_enabled) { true }
let(:mailgun_address) { "smtp.mailgun.org" }
let(:api_key) { nil }
it do
expect(check).to have_a_problem.with_priority("low").with_message(
"The server is configured to send emails via Mailgun but you haven't provided an API key used to verify the webhook messages.",
)
end
如果我们启用了回复,它会抱怨,但在这种情况下,我们不需要 webhook,并且
context "when replies are disabled" do
let(:replies_enabled) { false }
let(:mailgun_address) { anything }
let(:api_key) { anything }
it { expect(check).to be_chill_about_it }
end
在这里,我们没有 使用邮件接收器处理退信,并且我们对此感到满意。
是我糊涂了还是这是颠倒的?
好吧,也许是我糊涂了。邮件接收器似乎没有将退信通知 Discourse。一个繁忙的网站没有最近的退信。
但是:
和:
Régis Hanol:
要启用 VERP,请使用一个使用 + 符号的电子邮件地址模板设置“reply by email address”站点设置。默认的
replies+%{reply_key}@discourse.example.com
……工作正常。如果您使用的是您自己或您公司的电子邮件服务器,那么,就这样吧
您的 discourse 实例必须 能够接收发送到此地址的电子邮件。这应该可以通过 POP 实现,但我们强烈推荐 自托管站点的直接传递入站电子邮件
因此,这些文档表明,如果您有一个有效的邮件接收器,它应该处理这个问题。我曾经在我的一些内部工具中编写的代码,这些代码设置了这些 webhook,说“# 当我们有邮件接收器时不需要 webhook”。
3 个赞
我刚刚也遇到了这个问题。如果启用了邮件接收器,这个警告就毫无意义。我根据这里读到的内容(谢谢 Jay!)忽略了这个警告,但总觉得可以处理得更好。至少提供一个指向设置的链接,这样您就不必去寻找它了(剧透:它不在电子邮件设置中),并且在设置中提供一个更好的描述,提供更多细节,也许还有一个指向 meta 上文档主题的链接?
1 个赞
zogstrip
(Régis HANOL)
2026 年2 月 24 日 15:55
3
在调查此问题时,我注意到我们只对 Mailgun 进行了问题检查。因此,我做了一些小的重构,添加了一个全局的“邮件反弹处理”问题检查,它将适用于我们配置的所有邮件提供商。
main ← fix/email-bounce-handling-problem-check
opened 03:54PM - 24 Feb 26 UTC
The `MissingMailgunApiKey` problem check had inverted logic: it warned admins wh… en `reply_by_email_enabled` was true (meaning the mail receiver handles bounces via VERP, so no webhook API key is needed), but stayed silent when it was false (meaning bounces aren't being tracked at all). This caused false warnings on sites using the mail-receiver container.
This commit replaces the Mailgun-only check with a general `EmailBounceHandling` check that covers all supported email providers (Mailgun, SendGrid, Mailjet, Mandrill, Postmark, SparkPost, Mailpace, AWS SES). The check now correctly returns `no_problem` when both `reply_by_email_enabled` is true **AND** a VERP-capable reply address is configured, since bounces are handled by the mail receiver in that case.
For providers that previously accepted unauthenticated webhooks with only a log warning (SendGrid, Mailjet, Mandrill, Postmark, SparkPost), the behavior is preserved but upgraded to a Discourse.deprecate call (since 2026.2, drop 2026.5) to signal that authentication will be enforced in a future release.
Additionally:
- Adds Mailpace webhook signature verification (was previously missing)
- Adds the mailpace_verification_key site setting
- Includes a migration to clean up orphaned `problem_check_trackers` rows from the old `missing_mailgun_api_key` check
https://meta.discourse.org/t/305909
2 个赞