fix: repaired smtp configuration for port 587
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-03-16 14:00:23 +01:00
parent 837f5fd5bf
commit e95c1d6254
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
6 changed files with 138 additions and 20 deletions

View file

@ -111,7 +111,7 @@ defmodule Mv.Mailer do
do: :verify_peer,
else: :verify_none
[
base_opts = [
adapter: Swoosh.Adapters.SMTP,
relay: host,
port: port,
@ -120,11 +120,20 @@ defmodule Mv.Mailer do
auth: :always,
username: username,
password: password,
# tls_options: STARTTLS (587); sockopts: direct SSL (465). Verify from :smtp_verify_peer (ENV SMTP_VERIFY_PEER).
tls_options: [verify: verify_mode],
sockopts: [verify: verify_mode]
# tls_options: used for STARTTLS (587). For 465, gen_smtp uses sockopts for initial ssl:connect.
tls_options: [verify: verify_mode]
]
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
# Port 465: initial connection is ssl:connect; pass verify in sockopts so server cert is not required.
# Port 587: initial connection is gen_tcp; sockopts must NOT contain verify (gen_tcp rejects it).
opts =
if ssl_mode == "ssl" do
Keyword.put(base_opts, :sockopts, verify: verify_mode)
else
base_opts
end
opts |> Enum.reject(fn {_k, v} -> is_nil(v) end)
else
[]
end