Skip to content

Commit

Permalink
Attempt to fix SSL connectivity for system mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
wmnnd committed Oct 11, 2023
1 parent 6af1085 commit 0025ad9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if config_env() == :prod do
from_email = System.get_env("MAILER_SMTP_FROM_EMAIL") || user
password = System.fetch_env!("MAILER_SMTP_PASSWORD")
port = System.get_env("MAILER_SMTP_PORT", "587") |> maybe_to_int.()
ssl? = System.get_env("MAILER_ENABLE_SSL", "FALSE") in [1, "1", "true", "TRUE"]

[
adapter: Swoosh.Adapters.SMTP,
Expand All @@ -86,6 +87,15 @@ if config_env() == :prod do
from_email: from_email
]
|> put_if_not_empty.(:port, port)
|> then(fn config ->
if ssl? do
config
|> Keyword.put(:ssl, true)
|> Keyword.put(:sockopts, :tls_certificate_check.options(host))
else
config
end
end)
end

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

0 comments on commit 0025ad9

Please sign in to comment.