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

24 lines
542 B
Elixir
Raw Normal View History

2019-07-25 15:56:03 +00:00
defmodule Backend.Mailer.AdminEmail do
2019-08-21 12:30:47 +00:00
@moduledoc """
Module for sending emails to the server administrator.
"""
2019-07-25 15:56:03 +00:00
import Swoosh.Email
import Backend.Util
require Logger
def send(subject, body) do
admin_email = get_config(:admin_email)
if admin_email != nil do
new()
|> to(admin_email)
2021-07-30 16:53:51 +00:00
|> from("noreply@index.community")
2019-07-25 15:56:03 +00:00
|> subject(subject)
|> text_body(body)
|> Backend.Mailer.deliver!()
else
Logger.info("Could not send email to admin; not configured.")
end
end
end