Skip to content

Commit

Permalink
Always use SMTP_FROM
Browse files Browse the repository at this point in the history
Signed-off-by: Andrés Vidal <[email protected]>
  • Loading branch information
andres-vidal committed Jun 4, 2024
1 parent 1718e4f commit 8d407ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/lib/richard_burton/mailer_smtp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ defmodule RichardBurton.Mailer.SMTP do
end

@spec get_swoosh_email(RichardBurton.Email.t()) :: Swoosh.Email.t()
defp get_swoosh_email(email = %{address: address, subject: subject, message: message, to: nil}) do
defp get_swoosh_email(email = %{message: message, to: nil}) do
new(
from: {get_contact_name(email), address},
from: {System.get_env("SMTP_NAME"), System.get_env("SMTP_FROM")},
to: System.get_env("SMTP_FROM"),
subject: subject,
subject: get_subject(email),
text_body: message
)
end
Expand All @@ -55,6 +55,9 @@ defmodule RichardBurton.Mailer.SMTP do
)
end

defp get_subject(email = %{address: address, subject: subject}),
do: "#{subject} (from #{get_contact_name(email)}<#{address}>)"

defp get_contact_name(%{name: name, institution: nil}), do: name
defp get_contact_name(%{name: name, institution: ""}), do: name
defp get_contact_name(%{name: name, institution: institution}), do: "#{name} (#{institution})"
Expand Down

0 comments on commit 8d407ff

Please sign in to comment.