Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver

Discourse is all about enabling civilized discussion. While plenty of people like a web interface, e-mail is still the “hub” of many people’s online lives. That’s why sending e-mail is so important, and when you’re sending e-mail, you really want to be able to receive it, too. There are several reasons why:

  • If e-mails “bounce” (they can’t be delivered for some reason), you need to know about that. Repeatedly sending e-mails that bounce will get your e-mails flagged as spam. Receiving e-mail bounces allows you to disable sending to non-existent addresses.
  • Allowing people to reply to posts via e-mail can significantly improve engagement, as people can reply straight away from their mail client, even if they’re not able to visit the forum at that moment.
  • Letting people post new topics, or send PMs, via e-mail has similar benefits to engagement. In addition, you can use Discourse to handle e-mail for a group, such as an e-mail-based support channel (which is how Discourse’ own e-mail support is handled).

Delivering e-mail directly into your Discourse forum, rather than setting up POP3 polling, has a number of benefits:

  • No need to deal with gmail or another provider’s foibles;
  • You have more control over the e-mail addresses that people use to send posts; and
  • There are no delays in delivery – no more waiting for the next polling run to see new posts appear!

This howto is all about getting that hawtness into your forum.

Overview

This procedure creates a new container on your Discourse server, alongside the typical app container, which receives e-mail and forwards it into Discourse for processing. It supports all e-mail processes: handling bounces, replies, and new topic creation. Any self-hosted Discourse forum using our supported installation process can make use of this procedure to get easy, smooth-flowing incoming e-mail.

Container Setup

We’re going to get the mail-receiver container up and running on the server that’s already running your Discourse instance. There’s no need for a separate droplet just to handle mail – the whole container only takes about 5MB of memory!

So, start off by logging into your Discourse server, and becoming root via sudo:

ssh ubuntu@192.0.2.42
sudo -i

Now, go to your /var/discourse directory and create a new mail-receiver.yml container definition from the sample conveniently provided:

cd /var/discourse
git pull
cp samples/mail-receiver.yml containers/

Since every site is unique, open containers/mail-receiver.yml in your preferred text editor and change the MAIL_DOMAIN, DISCOURSE_BASE_URL, and DISCOURSE_API_KEY variables to suit your site. (If you are an advanced user and know that you are using nginx outside your container, see below for additional configuration for external nginx.)

:bulb: If you use the default mail endpoint (/admin/email/handle_mail), we suggest using the receive_emails API key scope to provide an extra layer of security.

If you’re not sure what your favourite text editor is, try nano:

nano containers/mail-receiver.yml

Use Ctrl-X to exit (say “Yes” to “Do you want to save changes?”, or all your work will be for nothing).

Now, do an initial build of the container, and fire it up!

./launcher bootstrap mail-receiver
./launcher start mail-receiver

To check everything’s OK, take a peek in the logs:

./launcher logs mail-receiver

The last line printed should look rather a lot like this:

<22>Aug 31 04:14:31 postfix/master[1]: daemon started -- version 3.1.1, configuration /etc/postfix

If so, all is well, and you can go on to then next step.

DNS Setup

In order for everyone else on the Internet to know where to deliver mail, you must create an MX record for your forum. The exact details of how to do this vary by DNS provider, but in general, the procedure should be very similar to how you setup the DNS records for your forum in the first place, except that instead of creating an A (or “Address”) record, you’re creating an MX (or “Mail eXchange”) record. If your forum is at forum.example.com, and you set MAIL_DOMAIN to forum.example.com in the mail-receiver.yml, then the DNS record should look like this:

  • DNS Name: forum.example.com (this is the MAIL_DOMAIN)
  • Type: MX
  • Priority: 10
  • Value: forum.example.com (this is the domain of your forum)

To make sure the DNS is setup correctly, use a testing site such as http://mxtoolbox.com/ to look up the MAIL_DOMAIN you configured, and make sure it’s pointing to where you expect.

Note: outbound email providers like mailgun may ask you to add MX records pointing to their servers. You want to remove these so the MX records for your forum only point to your forum’s domain name. SPF and DKIM records must still point to your outbound email provider servers so you can send email.

Discourse Configuration

Now e-mail is being fed into Discourse, it’s time to explain to Discourse what to do with the e-mail it receives.

  • Log into your Discourse forum as Admin and navigate to the Admin panel’s Site Settings, then click the Email tab. (forum.example.com/admin/site_settings/category/email)
  • Change the following settings:
    • Enable the reply by email setting
    • In the reply_by_email_address field, enter replies+%{reply_key}@forum.example.com
    • Enable the manual polling setting

You can automatically, without any further setup, use any address @forum.example.com as an address for category or group e-mails.

Troubleshooting

Nothing ever goes according to plan. Here’s how to figure out what went wrong.

  1. OCI runtime create failed error running ./launcher start mail-receiver? Your hostname might be too long. Rename it using these instructions and choose a shorter name, then rebuild.
  2. Did the e-mail even make it to mail-receiver? Run ./launcher logs mail-receiver, and look for log entries that mentions the address that the e-mail was sent from and to. If there’s none of those, then the message never even made it, and the problem is upstream. Check MX records, sending mail server logs, and firewall permissions (SMTP port 25).
  3. Is the message stuck in the queue? Run ./launcher enter mail-receiver, then run mailq. It should report, “Mail queue is empty”. If there’s any messages in there, you’ll get the to/from addresses listed. Messages only sit around in the queue if there’s a problem delivering to Discourse itself, so exit out of the container and then check…
  4. Did mail-receiver error out somehow? Run ./launcher logs mail-receiver | grep receive-mail and look for anything that looks like a stack trace, or basically anything other than “Recipient: <something>@forum.example.com”. Those error messages, whilst not necessarily self-explanatory, should go an awfully long way to explaining what went wrong. Look for typos in your yml file. In particular, check that DISCOURSE_BASE_URL matches your site URL, usually starting with https://.

Integrating with External nginx

If you are an advanced user and have configured external nginx such as for Add an offline page to display when Discourse is rebuilding or starting up you will find that the combination of mail-receiver and HTTPS being handled in external nginx requires slightly different handling to enable SSL for email over TLS. Here are example containers/mail-receiver.yml snippets that work with the recommended configuration for external nginx with letsencrypt certificates:

  POSTCONF_smtpd_tls_key_file:  /letsencrypt/live/=DOMAIN=/privkey.pem
  POSTCONF_smtpd_tls_cert_file:  /letsencrypt/live/=DOMAIN=/fullchain.pem

…

volumes:
  - volume:
      host: /var/discourse/shared/mail-receiver/postfix-spool
      guest: /var/spool/postfix
# uncomment to support TLS
  - volume:
      host: /etc/letsencrypt/
      guest: /letsencrypt

Note that you can’t export as a volume only /etc/letsencrypt/live because the actual files are symlinks into ../../archive/... and those won’t resolve if you are more specific in the volume specification.

Prevent outgoing host email from interfering (Postfix)

If you have (or want) automated messages from your host server (via Postfix), the mail-receiver will conflict because it needs port 25 to operate. One solution is to disable the host Postfix from listening on port 25:

nano /etc/postfix/master.cf

and comment out the line that looks like this:

smtp inet n - y - - smtpd

Then service postfix reload. You may also need to restart the mail-receiver container.

With both the host Postfix and the mail-receiver running, do netstat -tulpn | grep :25 to confirm that docker-proxy is using port 25.

Block unwanted domains from sending to you

To stop email from unwanted domains from even reaching your Discourse, your mail-receiver.yml should look something like this:

  DISCOURSE_API_USERNAME: system

  POSTCONF_smtpd_sender_restrictions: 'texthash:/etc/postfix/shared/sender_access'

volumes:
  - volume:
      host: /var/discourse/shared/mail-receiver/postfix-spool
      guest: /var/spool/postfix
  - volume:
      host: /var/discourse/shared/mail-receiver/etc
      guest: /etc/postfix/shared
# uncomment to support TLS
#  - volume:
#      host: /var/discourse/shared/standalone/letsencrypt
#      guest: /letsencrypt

Then create /var/discourse/shared/mail-receiver/etc path, and within it create a sender_access file containing the domains to reject, like this:

qq.com REJECT
163.com REJECT

Rebuild and you’re golden!

DMARC support

DMARC support has been enabled by default in the discourse/mail-receiver:release image to more strongly validate incoming email. This is enabled since the timestamped image discourse/mail-receiver:20240720054629.

This functionality can be toggled via the INCLUDE_DMARC docker environment variable. If a more permissive incoming mail server configuration is preferred, set that environment variable to false and rebuild the image.

The last version without DMARC support is discourse/mail-receiver:20211208001915.

Further Reading

Last edited by @kelv 2024-07-22T03:53:51Z

Check documentPerform check on document:
96개의 좋아요
Can Discourse ship frequent Docker images that do not need to be bootstrapped?
Protonmail bridged SMTP in Discourse
E-mail polling on GMAIL not working
POP3 Authentication with CRAM-MD5
Whether it is possible to set the possibility of answering the noreply@mydomain.com adress?
Is there a way to use IMAP instead of POP3 for replies by email?
Configure VERP to handle bouncing e-mails
Does Discourse Need Incoming Mail?
Setting Up Mail
How to migrate from Yahoo groups to Discourse
Troubleshooting Gmail 'Poll via POP3 for email replies'
Bad CSRF with mailgun replies
Reply via email failed
Incoming e-mail not received
Trying to set up reply by email: ActionController::RoutingError (No route matches [POST] "/admin/email/handle_mail")
Joe's Personal Discourse Theme
Additional email address per user account support
How %{reply_key} create?
Allow inbound email delivery to forum contact email for inactive users
How %{reply_key} create?
Code for receiving emails via Discourse API
Incoming e-mail not received
Incoming e-mail not received
Incoming e-mail not received
'hostname "mail.domain.tld" does not match the server certificate' :: SNI support? & how to query cert from Discourse container?
'hostname "mail.domain.tld" does not match the server certificate' :: SNI support? & how to query cert from Discourse container?
Will g-suite POP3 stop working on 2/15/2021
How to reset or recreate direct-delivery's mail-receiver container?
No received mails in new Discourse installation
Can I run wordpress in the same VPS with a second IP?
How might we better structure #howto?
MKJ's Opinionated Discourse Deployment Configuration
Create new email address on forum domain
Emailed topics arrive only once per hour as opposed to instantly
Can I use SES for sending and Gsuite for receiving email?
Reply via email setup with Exchange 2016
Set up Microsoft Teams notifications using the discourse-chat-integration plugin
Disable reply via email?
Need help with reply by email
Reply Mailinglist
How hard is it to handle Discourse after installation
(Can we?) Redirect all unrouted incoming emails to a category
Installation by the book
Learnings from setting up neighborhood community on Digital Ocean
Question about the email address domain used by Discourse
Configuring both direct delivery email and a forwarding rule
Configuring both direct delivery email and a forwarding rule
Able to receive e-mail in mail-receiver but NOT in Discourse?
Able to receive e-mail in mail-receiver but NOT in Discourse?
Email in main domain or sub-domain for the forum?
Mail receiver app
Configuring AWS SES for outgoing, bounce, and incoming email
Notes on Silencing or Deleting users
Self-hosted mail-receiver update following Let's Encrypt root certificate change
Use aliases in iRedMail for categories with incoming email feature enabled
Discourse Mailgun Routes
Reply-by email pop3 auth failure
Bounces not being received in Discourse with local Postfix server
AWS SES / AWS Lambda mail receiver endpoint code?
Mail questions and problems
Email forward ends up in original topic
Update mail-receiver to the release version
Customize direct-delivery Postfix configuration
User mentioned emails
Troubleshoot reply by email
Set up reply by email with POP3 polling
How to deactive account of those users who're not receiving emails
Filter known-bad sender domains from your mail-receiver
Receiving emails into Discourse messages. Can this be done?
How to change the number of unicorns?
Trying to setup direct delivery of incoming email and new topic by email
Setting up a support inbox
Setting up a support inbox
When an existing staged user Joins my site, filled in user custom fields data isn't saved
Moving to Another VPS Provider
Enable receiving and reply emails
Enable receiving and reply emails
Late bounce messages when users reply to to direct messages via email
Want to set internal forum on our reactjs member's platform
Simple email inbox for discourse
Separate envelope-from and reply-to email addresses to avoid DMARC failure
Enable receiving and reply emails
What exact email address do I use for “Custom Incoming email address”?
Where do I put the variables for mail-receiver?
Install Discourse on an isolated CentOS 7 server
Discourse needs better search
Mailgun api key check backward (no API key should be required if bounces handled by mail receiver)
Mail-receiver won’t deliver mail to Discourse
Help understanding email setup
Mail Receiver setup
Does the mail-receiver work with arm?
How to configure Discourse to receive email from Mailgun?
Installing discourse for free?
Connection to the POP3 server is timing out
Can a single Mail Receiver handle emails for all sites in a Discourse multisite setup?
Mail-receiver relay access denied
Mail-receiver lacks an official ARM-compatible image
Mail-Receiver Configuration: 403 Error on smtp_should_reject Endpoint
Personal Message Replies Not Displaying in Inbox When Initiated via Auto-Quoted Post
Changing email SMTP From
Email receive issue
Enabling reply_by_email
📬 Repeated Postfix warnings and connections after valid_recipients implementation
Restore backup to a local instance in a safe/anonymized way
Introduction to development for notification mail sending with Gmail
Using "email in" feature for a Gmail account with AWS SES SMTP settings
Auto-restarting once a day via cron?
Bottom line: Is Discourse now $12/month minimum on DigitalOcean? 😔 [Not yet! :slight_smile:]
Self hosted Reply by Email stopped working after latest update
Replying through email suddenly stopped due to Let's Encrypt changes
Doc clarification: reply-key addresses in Cc (not just To) are processed
Custom domain email with discourse DO setup
Where do I put the variables for mail-receiver?
Admin Interface and capabilities
Whether it is possible to set the possibility of answering the noreply@mydomain.com adress?
Generate LetsEnrypt certificates so mail-recevier can use them
Allow for email re-writing to solve the additional email address?
Webhook to forward posts to a mailinglist: best practice?
"Discourse::NotFound" error when click "Email Type" field on admin/email/bounced
Looking for email hosting service recommendations
Creating a topic via email without write access to the category?
Bad CSRF with mailgun replies
Bad CSRF with mailgun replies
[Paid] Discourse configuration changes
Allowing topic creation through direct delivery email in makes my forum vulnerable to spammers
Incoming e-mail not received
Failed to POST the e-mail (301 error)
Reply by Email, Gsuite, Limited users, Aliases?
Can I start a new topic by sending an email message?
NOQUEUE: reject using Direct Email Delivery
Started getting 'Unknown To: Address" failures
Can I run wordpress in the same VPS with a second IP?
Getting 'address not found' error trying to set up reply via email

7개의 게시물이 새 주제로 분리되었습니다: 메일 수신기가 arm에서 작동하나요?

이 컨테이너는 이메일을 email이라는 이름의 파라미터로 인코딩하는 것 같습니다:

/logs에 따르면 이는 비추천(deprecated) 상태인 것 같습니다:

Deprecation notice: warning: the email parameter is deprecated. all POST requests to this route should be sent with a base64 strict encoded email_encoded parameter instead. email has been received and is queued for processing (removal in Discourse 3.3.0) 

비추천 파라미터를 제거하기 전에 이 부분을 업데이트해 주실 수 있을까요? :innocent:

6개의 좋아요

설정 과정에서 참고할 점 몇 가지:

  • 새로운 컨테이너 구성 파일 containers/mail-receiver.yml을 chmod o-rwx containers/mail-receiver.yml 명령으로 반드시 보호하세요. 이 작업을 하지 않으면 컨테이너를 부트스트랩할 때 해당 작업을 수행하도록 프롬프트가 표시됩니다.
  • API 키를 생성할 때 "All Users"와 “Global” 범위를 선택했습니다. 더 제한적인 키가 작동하는지는 알 수 없습니다.
  • 샘플 mail-receiver.yml 파일의 TLS 설정이 상당히 다르므로, 샘플 파일을 수정하는 대신 여기의 지침을 따르는 것이 좋습니다.
  • 또한 smtpd_tls_security_level 설정이 포함되어 있으며, 저는 이 주석을 해제했습니다. 이 설정이 필요한지, 아니면 “may” 대신 다른 설정을 사용하는 것이 더 나은지에 대한 조사는 하지 않았습니다.
  • 특정 카테고리에 대한 이메일을 설정하려면 /c/{category-name}/edit/settings에서 수행할 수 있습니다. (이메일 목록과 유사한 카테고리를 만들려는 경우 유용합니다.) 그룹의 경우 /g/{group-name}/manage/interaction에서 이메일 주소를 설정할 수 있습니다.

이 내용이 다른 분들에게 도움이 될지 모르겠지만, 제게는 도움이 되었을 것입니다. :wink:

4개의 좋아요

최소 권한 원칙에 따른 API 키를 사용하는 것이 좋습니다. 다음 설정은 definitely 작동합니다:

사용자 수준: 모든 사용자
범위: 세분화된(Granular)
이메일 — 이메일 수신

5개의 좋아요

제가 볼 때 설정은 문제가 없어 보이지만, Discourse에 이메일 관련 기록이 전혀 없습니다.

로그에는 이메일이 다음과 같이 표시됩니다:

Mar 18 17:20:41 [myserver]-mail-receiver postfix/smtpd[122]: NOQUEUE: reject: RCPT from [XXX].google.com[XXX.XX.XXX.XXX]: 554 5.7.1 <test004@www.[mysite].com>: Recipient address rejected: Mail to this address is not accepted. Check the address and try to send again?; from=<[sender]@gmail.com> to=<test004@www.[mysite].com> proto=ESMTP helo=<[XXX].google.com>
Mar 18 17:20:42 [myserver]-mail-receiver postfix/smtpd[122]: disconnect from [XXX].google.com[XXX.XX.XXX.XXX] ehlo=2 starttls=1 mail=1 rcpt=0/1 bdat=0/1 quit=1 commands=5/7

또한 발신 주소로도 거절 알림이 수신됩니다. 큐에 남아 있는 것이 없고, 로그에도 추적 가능한 오류가 없습니다. URL이 모두 일치하는지 세 번이나 확인했으며, API 설정 페이지에서는 키가 사용 중임을 보여줍니다. 하지만 관리자 패널의 거절된 이메일 목록은 여전히 비어 있습니다.

제안이 있으신가요?

에러는 MAIL_DOMAIN이 www.[mysite].com으로 설정되어 있지 않거나, test004@www.[mysite].com으로 전송된 이메일을 받을 수 있도록 구성된 카테고리나 그룹이 없음을 나타냅니다.

1개의 좋아요

답변해 주셔서 감사합니다. MAIL_DOMAIN을 상상할 수 있는 모든 방법으로 확인해 보았고, MAIL_DOMAIN 값과 수신 이메일 주소를 조합한 모든 경우를 시도해 보았습니다. Discourse 설정에서 이 값은 예를 들어 DISCOURSE_HOSTNAME, DISCOURSE_SMTP_DOMAIN, 또는 다른 어떤 값과 비교되는 것인가요?

OP의 이 줄을 고려할 때, 두 번째 제안에 대해 다소 혼란스럽습니다:

Discourse가 이메일을 처리하도록 설정되기 전에 거절된 이메일이 표시되어야 하는 것 아닌가요? 바운스(반송)도 표시되지 않습니다. 여기에서 권장하는 방법으로 테스트해 보았지만 VERP를 구성하여 바운스되는 이메일 처리 admin/email에서 아무 흔적도 찾을 수 없습니다.

mail-receiver와 app 간의 상호작용에 대해 더 많은 정보를 표시하거나(또는 표시하도록 구성할 수 있는) 컨테이너 중 어딘가에 로그가 있나요?

1개의 좋아요

거부는 크게 두 가지 유형이 있습니다. 하나는 초기 단계에서 발생하여 이메일이 Discourse의 EmailReceiver로 전달될지 여부를 결정하는 것이고, 다른 하나는 Discourse의 이메일 처리 과정에서 발생하는 것입니다.

제 경험상 전자는 Discourse 로그에 표시되지 않습니다. 즉, 대부분의 이메일 관련 거부 사례(DMARC 실패, 잘못된 주소 등)는那里에 표시되지 않습니다. 표시되는 항목은 이메일이 너무 짧음, 사용자가 게시를 허용받지 못함 등의 경우입니다.

그 단락이 작성된 이후로 상황이 바뀌었는지는 확신이 없으나, 약 2.5년 전 제가 설정을 할 때부터 지금까지 제 경험은 위와 같습니다.

test-reject@[my-instance]로 이메일을 보내면, 이메일 제공업체(마일-리시버/Discourse가 아닌)로부터 수신자 주소가 거부되었다는 일반적인 바운스(bounce) 통지를 받습니다. 이는 mail-receiver가 SMTP 상호작용 중에 이를 거부하기 때문입니다.

바운스와 VERP는 수신 이메일이 아니라 Discourse 인스턴스가 보내는 이메일과 관련이 있습니다. 예를 들어, 일관되게 바운스되는 주소로 알림 이메일을 보내는 것을 자동으로 중단하는 것 등이 해당됩니다. 이들은 mail-receiver와는 관련이 없습니다.


제 추측은 가이드에서 인용한 부분이 혼란을 야기한 것이며, 실제로는 모든 것이 정상적으로 작동하고 있을 가능성이 높다는 것입니다. some-random-address@MAIL_DOMAIN으로 보내면 받아들여지지 않고 거부 목록에 표시되지 않으므로, 이는 그 자체로는 매우 유용한 테스트가 아닙니다(마일-리시버가 이메일을 수신하고 있는지 확인하는 것 제외, 이는 이미 확인했습니다).

기존 카테고리로 이동하거나 새 카테고리를 생성하고, 설정을 열어 설정 탭으로 가세요. 하단 근처에서 custom incoming email address(사용자 정의 수신 이메일 주소)를 찾을 수 있습니다. 이를 something@MAIL_DOMAIN(예: 이전에 시도했던 test004 주소)으로 설정하고 저장한 후, 해당 주소로 전송을 시도해 보세요.

이 경우 mail-receiver를 통과하므로, 카테고리에서 새 게시물이 생성되거나 Discourse에서 거부 메시지가 표시되어야 합니다.

1개의 좋아요

감사합니다. 매우 도움이 되는 설명입니다. 설정을 마치고 테스트해 보겠습니다.

바운스(Bounces) 관련해서도 OP(원포스터)의 설명 때문에 다시 혼란스러웠습니다. 바운스는 이 가이드를 따를 수 있는 이유 목록에서 첫 번째 항목이었기 때문이죠.

즉, 이렇게 설정을 마쳤고 Mailgun의 MX 레코드를 제거했더라도, 바운스 등을 처리하기 위해 해당 쪽에서 VERP를 구성해야 한다는 말씀이신가요? 아, 실망입니다. 직접 전송(Direct Delivery)이 제 Mailgun 웹훅 문제의 대안이 될 줄 알았는데, 다시 웹훅 문제를 디버깅해야 할 것 같습니다.

2개의 좋아요

아, 죄송합니다. 바운스에 대해 mail-receiver를 사용할 수 있다는 말씀이 맞네요. 그 작동 방식에 대해 잘 모릅니다.

제 mail-receiver는 바운스를 받지 못하는데, 저는 Mailgun 웹훅을 사용하고 있습니다. 아마도 웹훅이 활성화되어 있으면 Mailgun이 봉투 발신자(envelope sender)를 변경해서 바운스를 수신하는 것 같습니다. (즉, 웹훅이 비활성화되어 있었다면 제 mail-receiver가 대신 바운스를 받았을 수도 있습니다.)

1개의 좋아요

네, git log를 확인해 보니 2017년 5월에 fast-rejection이 구현되었기 때문에 이제 그 정보는 부정확할 가능성이 매우 높습니다.

실제 설정, 특히 Discourse의 그룹/카테고리 설정을 직접 확인하지 않는 한 무엇이 잘못되었는지 말하기가 정말 어렵습니다. 하지만 80% 이상의 경우 어딘가에 오타가 있는 것입니다. 동료(기술적으로 깊이 있는 사람이 아니어도 됩니다)에게 설정을 살펴봐 달라고 하면, 아마도 i 대신 l을 입력한 부분을 5초 만에 찾아낼 것입니다. 제 아내가 저를 위해 이 일을 자주 해 줍니다.

그렇습니다. direct-delivery를 사용하면 수신 메일에 대해 발신 메일 제공사가 전혀 개입할 필요가 없습니다. 새 주제, 답변, 또는 바운스 메일 등 모든 것이 mail-receiver로 바로 전달되어야 합니다(그 후 처리를 위해 Discourse로 전달됨).

3개의 좋아요

지난주에도 저한테 정확히 같은 문제가 발생했을 때 아마도 그랬을 거라고 확신합니다. 결국 다른 곳에서 YML 파일을 복사해와서 사용하니 작동하더군요.

다만, 매트, 좀 이상하긴 했어요. postfix 파일을 확인했는데 그것도 정상으로 보였는데, 호스트명이 일치하지 않는다고 하더군요. 분명 복사/붙여넣기했다고 맹세하는데, 아마도 타이핑으로 입력해도 될 거라고 생각한 실수를 한 것 같습니다.

1개의 좋아요

AI 음성 인식 기술이 언젠가 이 모든 문제를 해결해 주리라니 다행입니다. :troll:

3개의 좋아요

말씀하신 대로 카테고리 이메일을 설정하고 해당 주소로 이메일을 보내니 예상대로 작동했습니다. 즉, 거절이 조용하게 처리되었기 때문에 제가 혼자서 고군분투하고 있었던 거였네요.

이제 알게 되어 다행입니다. 개인적으로는 가이드에 설명된 대로 작동하는 것이 더 좋았겠지만, 가이드가 업데이트되기를 바랍니다. 예를 들어, 사용자가 특정 주소로 이메일을 보내려다 실패하는 경우, 이를 알려주거나 카테고리나 그룹에 이메일로 소통하려는 수요가 있다는 것을 알아차릴 수 있게 해주는 것이 도움이 될 것입니다. 그렇지 않으면 그런 이메일을 확인할 쉬운 방법이 없는 것 같습니다.

여전히 예상대로 작동하지 않습니다. 웹훅은 작동하도록 설정해서 몇 개의 바운스를 확인할 수 있지만, Mailgun 웹훅에서 온 것임을 알고 있습니다. 여기 설명된 문제가 있기 때문입니다: 관리자 화면의 admin/email/bounced에서 “Email Type” 필드를 클릭할 때 발생하는 “Discourse::NotFound” 오류

MX 레코드가 Mailgun 서버를 가리키지 않는 상황에서 Mailgun이 어떻게 바운스를 받는 것인지 잘 이해가 되지 않습니다. 발신 메일을 보낼 때 리턴 패스(return path)를 설정하고 있다고 추정하고 있습니다.

mail-receiver 로그에서 바운스를 볼 수 있지만, app에는 도달하지 않습니다. 조용히 거부되는 것으로 보입니다. 웹훅을 통해 받은 바운스와 연결할 수 있는 로그의 한 줄은 다음과 같습니다:

NOQUEUE: reject: RCPT from mail-[id1].outbound.protection.outlook.com[XX.XX.XX.XX]: 450 4.7.1 <bounce+[id2]-[email]=[address].com@www.[mydomain].com>: Recipient address rejected: Internal error, API request failed; from=<> to=<bounce+[id#]-[email]=[address].com@www.[mydomain].com> proto=ESMTP helo=<[id3].outbound.protection.outlook.com>

이메일이 통과하도록 어딘가에 bounce+{%something}@www.mydomain.com을 화이트리스트에 추가해야 하나요?

2개의 좋아요

네, 나가는 이메일이 그들의 서버를 통과할 때 반환 경로(또는 “envelope from”)를 재작성하는 것 같습니다. 아마도 그것을 끄는 설정이 어딘가에 있을 것 같지만, 저는 Mailgun을 사용해 본 적이 없어서 정확히 말할 수 없으며(또는 그런 설정이 어디에 있는지)도 알 수 없습니다.

음, 그것은 메일 수신기와 Discourse 사이의 오류입니다. 곧 그 직전에 "Failed to GET smtp_should_reject answer"로 시작하는 로그 줄이 하나 있을 텐데, 그것이 실패한 내용과 이유에 대해 더 많은 정보를 제공하며, 이는 Discourse 로그의 어떤 오류 메시지와도 일치해야 합니다.

2개의 좋아요

Mar 21 17:02:21 discourse-smtp-fast-rejection[1149]: Failed to GET smtp_should_reject answer from https://www.mydomain.com/admin/email/smtp_should_reject.json: 400

빈 발신자(from=<>)와 관련이 있을까요? 로그에는 이에 대한 내용이 보이지 않습니다. 400 오류는 smtp_should_reject.json 파일이 존재하지 않는다는 의미인가요?

2개의 좋아요

해당 HTTP 리소스가 존재하지 않는다면 400이 아니라 404가 반환되어야 합니다. 나는 null 발신자가 문제가 될 거라고 생각하지 않습니다. 왜냐하면 모든 바운스(반송) 메일이 그렇게 전달되기 때문입니다. 잘못된 API 키는 (제가 생각하기에) 403을 반환해야 하지만, 머릿속으로 단번에 확신할 수는 없으므로 혹시 모를 경우를 대비해 최소한 확인해 볼 가치가 있습니다. Discourse 로그가 요청이 왜 잘못된 것인지에 대한 단서를 전혀 제공하지 않는다면, 아쉽게도 고통스러운 디버깅 세션을 감당해야 할 가능성이 높습니다. 현재 저는 mail-receiver 기능이 활성화된 시스템을 쉽게 가지고 놀 수 있는 상태가 아니기 때문입니다. 아쉽게도, 어떤 일이 일어나고 있는지 그 원인을 파악하고 이를 수정해 드리는 것은 저에게는 컨설팅 업무가 될 것입니다.

3개의 좋아요

현재로서는 아무것도 깨지지 않는 것 같습니다. 웹훅을 통해 바운스가 정상적으로 작동하고 있으며, 대부분의 바운스는 이메일을 생성하지 않습니다(다른 주제에서 언급된 이 Stack Overflow 답변과 일치하며, 제가 관찰한 내용과도 같습니다). 또한 이메일로 답장하는 기능도 정상적으로 작동하고 있습니다. 어떤 형태의 실패든 간에, 그 빈도는 드물며 정상적인 기능을 방해하지 않습니다.

혹시 모를 상황에 대비해 계속 주의를 기울이고, 다른 사람에게 도움이 될 만한 내용을 알게 되면 다시 보고하겠습니다. 다시 한번 도움을 주셔서 감사합니다!

2개의 좋아요

@JammyDodger 이 제목을 "mail-receiver"로 검색할 때 쉽게 찾을 수 있는 이름으로 변경할 수 있을까요? 3년 전 "straightforward"가 제목에서 제거된 이후로, 여러 번 시도해야 겨우 이 주제를 찾을 수 있었습니다.

4개의 좋아요