index.community/backend/lib/mailer/user_email.ex

22 lines
619 B
Elixir
Raw Normal View History

2019-07-26 14:34:23 +00:00
defmodule Backend.Mailer.UserEmail do
import Swoosh.Email
2019-07-26 14:41:32 +00:00
import Backend.{Auth, Util}
2019-07-26 14:34:23 +00:00
require Logger
@spec send_login_email(String.t(), String.t()) :: {:ok | :error, term}
def send_login_email(address, domain) do
frontend_domain = get_config(:frontend_domain)
body =
"Someone tried to log in to #{domain} on https://#{frontend_domain}.\n\nIf it was you, click here to confirm:\n\n" <>
get_login_link(domain)
new()
|> to(address)
|> from("noreply@fediverse.space")
|> subject("Login to fediverse.space")
|> text_body(body)
|> Backend.Mailer.deliver()
end
end