바운스 처리 시 smtp_should_reject "400 bad request" 오류 발생

안녕하세요!

저는 기본적으로 여기에서 설명된 것과 정확히 동일한 문제를 겪고 있습니다: Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver - #482 by Carleas

문제는 제가 받는 바운스 메일에 from 필드가 포함되어 있지 않아서, API 호출이 https://forum.example.com/admin/email/smtp_should_reject.json?from=&to=replies+verp-326f6e22828d2543ba65497a47608f13@mail.forum.example.com처럼 이루어질 때 다음 오류와 함께 400 상태 코드를 반환하기 때문인 것 같습니다:

{"errors":["param is missing or the value is empty or invalid: from"]}

mail-receiver 로그의 일부는 다음과 같습니다.

Nov 03 07:34:53 mail postfix/smtpd[1044]: connect from v-108-120-yyy-74-srvr1.xxx.com[74.91.xxx.108]
<19>Nov  3 07:34:53 discourse-smtp-fast-rejection[1048]: Failed to GET smtp_should_reject answer from https://forum.example.com/admin/email/smtp_should_reject.json: 400<22>Nov  3 07:34:53 policyd-spf[1049]: : prepend Received-SPF: None (no SPF record) identity=helo; client-ip=74.91.xxx.108; helo=v-148-29-xxx-192-srvr1.xxx.com; envelope-from=<>; receiver=mail.forum.example.com Nov 03 07:34:53 mail postfix/smtpd[1044]: NOQUEUE: reject: RCPT from v-108-120-yyy-74-srvr1.xxx.com[74.91.xxx.108]: 450 4.7.1 <replies+verp-326f6e22828d2543ba65497a47608f13@mail.forum.example.com>: Recipient address rejected: Internal error, API request failed; from=<> to=<replies+verp-326f6e22828d2543ba65497a47608f13@mail.forum.example.com> proto=ESMTP helo=<v-148-29-xxx-192-srvr1.xxx.com>

그러나, 올바른 from 주소(제 이메일을 넣는 경우)가 포함되어 있더라도 다음과 같은 응답이 돌아옵니다.

{"reject":true,"reason":"Mail to this address is not accepted. Check the address and try to send again?"}

따라서 이 경우에도 거부되었을 것입니다…

설정에서 놓치고 있는 부분이 있을까요? 어떻게 해야 하는지 도무지 알 수가 없습니다.

1개의 좋아요

안녕하세요! 죄송하지만 해당 주제에 대한 답변이 없네요. 문제를 스스로 해결하셨나요?

어떤 메일 제공업체를 사용 중이신가요?

아니요, 불행히도 바운스 메일을 받지 못하고 있습니다…

다만 CPanel의 SMTP 서버를 사용 중입니다.

아웃바운드 이메일 제공업체는 어떻게 되나요? Mailgun이나 다른 트랜잭션 이메일 제공업체를 사용하고 계신가요?

아니요. 같은 SMTP를 사용하고 있는데, 발신은 완벽하게 잘 되고 있고, 주제의 수신도 정상적으로 도착하고 있습니다. 문제는 바운스(수신 실패)가 포럼에 표시되지 않아 계속 재시도를 시도하고, 결국 호스팅 제공업체에서 경고 메시지를 받는 것입니다.

이 내용을 hosting 채널로 옮깁니다.

이런 문제에 대해 공식적인 답변은 안타깝게도 "이메일은 어렵다"는 것입니다. 트랜잭션 이메일 제공업체를 사용하시면 훨씬 더 좋은 결과를 얻을 수 있습니다.

예산이 있으시다면 Marketplace 채널에 게시하거나, 제가 이 주제를 해당 채널로 옮겨 드릴 수도 있습니다.

적어도 이 문제를 함께 살펴봐 주셔서 감사합니다!!

1개의 좋아요

DevTeVe 님,

해당 코드를 검토해 보았으며, DevTeVe 님의 지적이 옳다고 생각합니다. smtp_should_reject 코드가 바운스 메시지나 회신을 잘못 거부하고 있을 수 있습니다.

이 문제를 내부적으로 상급자에게 보고하겠습니다.

그동안 discourse-smtp-fast-rejection 정책 필터를 비활성화하면 메일 전송이 정상적으로 이루어지나요?

2개의 좋아요

와! 에스컬레이션해 주셔서 감사합니다! 조금은 절망적이었거든요 하하! discourse-smtp-fast-rejection을 비활성화해 볼게요 (다만 어떻게 해야 하는지 확실하지는 않지만, 찾아보고 다시 알려드릴게요)

1개의 좋아요

메일 수신기 postfix 설정 파일에서 이 줄을 삭제할 수 있다면:

smtpd_recipient_restrictions = check_policy_service unix:private/policy

이것으로 해결될 것입니다 - 테스트는 해보지 않았지만 작동할 것이라고 생각합니다:

postconf -e "smtpd_recipient_restrictions ="
1개의 좋아요

성공했습니다!

mail-receiver.yaml 파일을 이렇게 작성하고 있습니다 (잠시 동안만, 아니면 계속 이렇게 두어야 하나요? @supermathie)

# this is the incoming mail receiver container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild mail-receiver
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

base_image: discourse/mail-receiver:release
update_pups: false

expose:
  - "25:25"   # SMTP

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8

  ## Where e-mail to your forum should be sent.  In general, it's perfectly fine
  ## to use the same domain as the forum itself here.
  MAIL_DOMAIN: community.example.com
# uncomment these (and the volume below!) to support TLS 
  POSTCONF_smtpd_tls_key_file:  /letsencrypt/community.example.com/community.example.com.key
  POSTCONF_smtpd_tls_cert_file:  /letsencrypt/community.example.com/community.example.com.crt
  POSTCONF_smtpd_tls_security_level: may
  POSTCONF_myhostname: community.example.com
  POSTCONF_mynetworks: "127.0.0.0/8 [::1]/128 [fe80::]/64 172.17.0.0/16"
  POSTCONF_smtpd_recipient_restrictions: ""
  ## The base URL for this Discourse instance.
  ## This will be whatever your Discourse site URL is. For example,
  ## https://discourse.example.com. If you're running a subfolder setup,
  ## be sure to account for that (ie https://example.com/forum).
  DISCOURSE_BASE_URL: 'https://community.example.com'

  ## The master API key of your Discourse forum.  You can get this from
  ## the "API" tab of your admin panel.
  DISCOURSE_API_KEY: <YOURKEY>

  ## The username to use for processing incoming e-mail.  Unless you have
  ## renamed the `system` user, you should leave this as-is.
  DISCOURSE_API_USERNAME: system

volumes:
  - volume:
      host: /var/discourse/shared/mail-receiver/postfix-spool
      guest: /var/spool/postfix
# uncomment to support TLS
  - volume:
      host: /var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/
      guest: /letsencrypt
1개의 좋아요

일단 "지금은"이라고 하고, 새로운 소식이 있을 때 이 주제를 업데이트하겠습니다.

3개의 좋아요

정말 감사합니다! 이렇게까지 진행될 줄은 솔직히 기대하지 않았는데, 지금은 완벽해졌고 다른 바운스도 모두 받고 있습니다!

3개의 좋아요

여기서 후속 진행 중: Remove smtp_should_reject & discourse-smtp-fast-rejection

2개의 좋아요

이 주제는 마지막 답변 후 24시간이 지나면 자동으로 닫힙니다. 더 이상 새 답변을 할 수 없습니다.