Confusing mail settings documentation, non-working SSL/TLS on OTP26 / v3.2.0
After investing 4 - 5 hours of life time in configuring mail on Mobilizon 3.2.0 using the official docker image and the docker.exs
file from the 3.2.0 tag on GitLab I think I have a pretty good understanding what went wrong the past 5 hours. Let me try to document this before I forget and maybe there are some improvements for the docs in order.
So here a short summary of what I did:
- Following docker install instructions compose a compose file
- setting env vars
- trying SSL=true on port 465
- Noting that mail does not work
- Copying and modifying docker.exs from tag 3.2.0, mounted to
/etc/mobilizon/config.exs
- Spending 5 hours of debugging on SSL/TLS
- Using SSL=false on port 587 (with STARTTLS) instead which does work at least
So the error with SSL=true using an SSL/TLS endpoint on Mobilizon 3.2.0 with OTP26 seems to be that the new default for tls_options: verify:
is now :verify_peer
. Then the cacerts
variable is undefined
as it is already reported in other issues.
The error I saw was:
{:retries_exceeded, {:network_failure, ~c"smtp-server-ip", {:error, {:options, :incompatible, [verify: :verify_peer, cacerts: :undefined]}}}}
Apparently the tls_options
from the config file are not applied. Changing them to nonsensical things like foobar does not change the error or have any impact. Realizing this took me the most time I guess. Going through the latest docs on Swoosh I can't seem to find references of tls_options
in the docs nor the code, only in issues this is mentioned.
The mobilizon docs are using different examples in different parts. In Admin/Config/Email Swoosh
is used while in the reference uses Bamboo
(which does not work either if I recall correctly as the dependency is missing).
After reading in some Swoosh issue that Swoosh does not support SSL/TLS, only STARTTLS (not verified if that's true) I gave up and used SSL=false with STARTTLS on 587.
Side note: I added the config :logger, :console, format: "[$level] $message\n", level: :debug
line mentioned in logging docs to the config.exs but it did not change the logging seen via journalctl.
Resources:
- https://framagit.org/framasoft/mobilizon/-/blob/3.2.0/config/docker.exs?ref_type=tags
- https://github.com/swoosh/swoosh/issues/811
- #1352 (closed)
- https://github.com/swoosh/swoosh/issues/785
- !1456 (merged)
- https://github.com/swoosh/swoosh/blob/v1.14.1/lib/swoosh/adapters/smtp.ex#L1
- https://hexdocs.pm/swoosh/Swoosh.Adapters.SMTP.html
- https://www.erlang.org/blog/otp-26-highlights/#ssl-safer-defaults