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)
|
|
|
|
|> from("noreply@fediverse.space")
|
|
|
|
|> subject(subject)
|
|
|
|
|> text_body(body)
|
|
|
|
|> Backend.Mailer.deliver!()
|
|
|
|
else
|
|
|
|
Logger.info("Could not send email to admin; not configured.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|