refactor: adress review
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-03-12 15:29:54 +01:00
parent 4af80a8305
commit 942f2afd9e
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
8 changed files with 108 additions and 62 deletions

View file

@ -33,6 +33,7 @@ defmodule Mv.Mailer do
require Logger
# Simple format check for test-email recipient only (e.g. allows a@b.c). Not for strict RFC validation.
@email_regex ~r/^[^\s@]+@[^\s@]+\.[^\s@]+$/
@doc """
@ -105,6 +106,11 @@ defmodule Mv.Mailer do
password = Mv.Config.smtp_password()
ssl_mode = Mv.Config.smtp_ssl() || "tls"
verify_mode =
if Application.get_env(:mv, :smtp_verify_peer, false),
do: :verify_peer,
else: :verify_none
[
adapter: Swoosh.Adapters.SMTP,
relay: host,
@ -114,10 +120,9 @@ defmodule Mv.Mailer do
auth: :always,
username: username,
password: password,
# OTP 26+ enforces verify_peer; allow self-signed / internal certs.
# tls_options: STARTTLS upgrade (port 587); sockopts: direct SSL connect (port 465).
tls_options: [verify: :verify_none],
sockopts: [verify: :verify_none]
# 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]
]
|> Enum.reject(fn {_k, v} -> is_nil(v) end)
else