Skip to content

Commit

Permalink
Merge pull request #247 from pentacent/feature/system-mailer-starttls
Browse files Browse the repository at this point in the history
Add Starttls support for system mailer
  • Loading branch information
wmnnd authored Nov 3, 2023
2 parents e01428e + 61fae4a commit bab44bc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ if config_env() == :prod do
port = System.get_env("MAILER_SMTP_PORT", "587") |> maybe_to_int.()
ssl? = System.get_env("MAILER_ENABLE_SSL", "FALSE") in [1, "1", "true", "TRUE"]

starttls? =
System.get_env("MAILER_ENABLE_STARTTLS", "FALSE") in [1, "1", "true", "TRUE"]

[
adapter: Swoosh.Adapters.SMTP,
relay: host,
Expand All @@ -97,6 +100,15 @@ if config_env() == :prod do
config
end
end)
|> then(fn config ->
if starttls? do
config
|> Keyword.put(:tls, :always)
|> Keyword.put(:tls_options, :tls_certificate_check.options(host))
else
config
end
end)
end

config(:keila, Keila.Mailer, config)
Expand Down

0 comments on commit bab44bc

Please sign in to comment.