Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions lib/mailman/external_smtp_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ defmodule Mailman.ExternalSmtpAdapter do
Delivers an email based on specified config.
"""
def deliver(config, email, message) do
relay_config = [
relay: config.relay,
username: config.username,
password: config.password,
port: config.port,
ssl: config.ssl,
tls: config.tls,
auth: config.auth
]

from_envelope_address = email.from
to_envelope_address = email.to

Expand All @@ -27,7 +17,7 @@ defmodule Mailman.ExternalSmtpAdapter do
to_envelope_address,
message
},
relay_config
build_relay_config(config)
)

case ret do
Expand All @@ -36,4 +26,29 @@ defmodule Mailman.ExternalSmtpAdapter do
_ -> {:ok, message}
end
end

defp build_relay_config(%{hostname: nil} = config) do
[
relay: config.relay,
username: config.username,
password: config.password,
port: config.port,
ssl: config.ssl,
tls: config.tls,
auth: config.auth
]
end

defp build_relay_config(config) do
[
relay: config.relay,
username: config.username,
password: config.password,
port: config.port,
ssl: config.ssl,
tls: config.tls,
auth: config.auth,
hostname: config.hostname
]
end
end
1 change: 1 addition & 0 deletions lib/mailman/smtp_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule Mailman.SmtpConfig do
port: 1111,
ssl: false,
tls: :never,
hostname: nil,
auth: :always

end
Expand Down