Discourse와 Stalwart-mail로 완전 독립적인 이메일 구성

troubleshooting

Continuing the discussion from Stalwart-mail+Discourse: POP3 EOF reached (again):

Since @programmerjake is also exploring Discourse ↔ Stalwart-mail, I wanted to ask you whether you’re experiencing TLS errors on SMTPS:

2024-07-01T17:37:49.718793Z DEBUG common::listener: Failed to accept TLS connection: tls handshake eof context="tls" event="error" instance="smtps" protocol=Smtp remote.ip="128.140.68.114"
2024-07-01T17:37:49.899171Z DEBUG common::listener: Failed to accept TLS connection: tls handshake eof context="tls" event="error" instance="smtps" protocol=Smtp remote.ip="128.140.68.114"

On Discourse’s side, there’s an error popup:

ERROR - Net::ReadTimeout with #<TCPSocket:(closed)>

It seems to be related to Ruby’s OpenSSL library not supporting TLSv1.3, but this seems a bit far-fetched since it should be working with TLSv1.2 anyway.


Working installation

Stalwart-mail >= v0.8.3

That’s it, with this release, Stalwart-mail now supports both sending and receiving email with Discourse. :tada:

Stalwart-mail is a single binary mail service that covers all your email needs without the clutter of configuration that we’ve been used to over decades with Postfix + Spamassassin + Dovecot + etc. Here, you setup your installation and have everything ready to go, including full TLS automation with ACME and LetsEncrypt, SPF, DMARC, DKIM, ARC, DANE support out of the box (including reports from and to your domains), TLSA and other DNS records ready to go, auto-configuration and auto-discovery for easy mail client setup, shared folders (via “groups”), aliases, ManageSieve filters on all incoming and outgoing messages at various stages of the process, web administration, 2FA and TOTP support, OAUTH, and many more features. No need to externalize your email anymore!

  1. Use a submission listener on port 587 for SMTP
    1. disable implicit TLS (means: use STARTTLS)
    2. Ensure ignore client order is disabled (either in the defaults or override TLS options of the listerner)
  2. Enable a POP3 listener on port 995 with implicit TLS

Discourse

Configure email normally using 587 for Submission (with STARTTLS) and 995 for POP3s with SSL/TLS.

So this is an open source alternative to Mailgun and the like? That is starting to look very attractive as most of those services are quite pricey for low volumes.

I take it that it requires its own (virtual) machine. It would be amazing if it could easily run on the same machine as Discourse.

Do you know if one instance of Stalwart Mail could service several Discourse instances?

Yes, you can support multiple domains easily.

First you add a domain, then it gives you the DNS records to setup the MX (mail exchange). All your domains will be using the same MX.

It should be easy to run Stalwart-mail on the same machine as Discourse. Since both require TLS port 443, you would be using a proxy on that port to send to both services. But it does not make much sense to have one instance per Discourse, it’s better to separate the two, so you can scale up your email infrastructure easily, and cover more needs than just Discourse.

As an indication, I’ve been running Stalwart-mail on a CPX21 (4 GB RAM, 3 x86 AMD vCPUs, 80 GB storage) Hetzner VPS with about 30 accounts over a dozen domains, with full logs on, and it takes 564 MB RAM and 7 GB storage (most of them is the OS). Stalwart-mail claims 184 MB resident RAM (less than 5% of all RAM, and 1.2 GB virtual).

I’m using port 587 with STARTTLS and haven’t encountered any errors when testing just now…

also in Stalwart-mail’s logs it seems to be using TLSv1.3 and not running into any errors…I do have a slightly unusual config that I’m testing (using pebble to run a local ACME server and using a .test domain name, but that probably isn’t enough to break/fix anything…)

I’m not using “Override TLS options” in the port 587 listener…

지난 몇 달간 Stalwart-mail을 Discourse와 함께 독점적으로 사용해 왔는데, 아주 잘 작동합니다. 이제 Submission(587 포트, STARTTLS)과 Submissions(465 포트, TLS)를 모두 사용할 수 있습니다. 특별한 설정이나 셋업이 필요하지 않았습니다.

다만 주의할 점으로, 도메인 DNS 레코드 설정은 두 단계의 과정입니다.

  1. 먼저 Directory에 도메인 이름을 추가합니다. 이렇게 하면 DNS 존 파일에 추가할 리소스 레코드가 제공됩니다.
  2. DNS가 업데이트되면 해당 도메인에 대해 TLS 프로바이더를 생성합니다. 다음 호스트네임을 추가해야 합니다: mail, autoconfig, autodiscover, 그리고 mta-tls(도메인을 붙인 형태, 예: mail.example.org).[1]
  3. 잠시 후(수 초에서 수 분), 내부 ACME 프로바이더가 변경 사항을 감지하여 TLS 인증서를 발급합니다. 이 시점에 도메인 설정이 레코드를 업데이트합니다: 새로운 id를 가진 _mta-tls RR과 모든 _tlsa 레코드를 존 파일에 추가하면 준비가 끝납니다.

Stalwart-mail은 현재 매우 강력한 스팸 필터와 통합된 fail2ban 기능(인증 실패 또는 잘못된 URI를 요청한 IP 주소를 차단)을 갖추고 있습니다.


  1. 최소한의 Stalwart-mail + Discourse 구성의 경우, autoconfigautodiscover는 IMAP 클라이언트와 함께 유용하므로 아마도 필요하지 않을 것입니다. ↩︎