I was also struggling with this issue for a good while until I used almost the exact configuration mentioned here by @LostKobrakai SSL connection options · Issue #298 · gen-smtp/gen_smtp · GitHub
Here is my config which now (finally) works (using this smtp server)
config :backend, Backend.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: System.get_env("EMAIL_SMTP_HOST"),
username: System.get_env("EMAIL_SMTP_USER"),
password: System.get_env("EMAIL_SMTP_PASSWORD"),
port: String.to_integer(System.get_env("EMAIL_SMTP_PORT") || "465"),
ssl: true,
tls: :never,
auth: :always,
retries: 2,
no_mx_lookups: false,
sockopts: [
versions: [:"tlsv1.2", :"tlsv1.3"],
verify: :verify_peer,
cacerts: :public_key.cacerts_get(),
depth: 3,
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
],
server_name_indication: 'mail.privateemail.com'
]
It was pretty tough to figure this out as someone very new to Elixir, especially since I couldn’t find this sockopts key documented anywhere in Swoosh or the gen_smtp Readme and I still don’t really understand why this is necessary, but maybe it helps someone.
What was also really tripping me up for a bit was the fact that server_name_indication apparently needs to be a charlist (single quoted) and I was trying to set it as a string with System.get_env("EMAIL_SMTP_HOST").
Perhaps someone who understands this better than me could add a note about it to the Swoosh SMTP adapter docs, since without these settings it doesn’t seem to be possible to get it to work?






















