2019-09-17 02:45:32 +02:00
|
|
|
defmodule MobilizonWeb.Email do
|
|
|
|
@moduledoc """
|
|
|
|
The Email context.
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
|
|
|
|
|
|
|
alias Mobilizon.Config
|
|
|
|
|
2019-09-23 19:33:58 +02:00
|
|
|
@spec base_email(keyword()) :: Bamboo.Email.t()
|
|
|
|
def base_email(args) do
|
|
|
|
instance = Config.instance_config()
|
|
|
|
|
|
|
|
new_email(args)
|
2019-09-17 02:45:32 +02:00
|
|
|
|> from(Config.instance_email_from())
|
2019-09-23 19:33:58 +02:00
|
|
|
|> put_header("Reply-To", Config.instance_email_reply_to())
|
|
|
|
|> assign(:instance, instance)
|
2019-09-17 02:45:32 +02:00
|
|
|
|> put_html_layout({MobilizonWeb.EmailView, "email.html"})
|
2019-09-23 19:33:58 +02:00
|
|
|
|> put_text_layout(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
def premail(email) do
|
|
|
|
html = Premailex.to_inline_css(email.html_body)
|
|
|
|
text = Premailex.to_text(email.html_body)
|
|
|
|
|
|
|
|
email
|
|
|
|
|> html_body(html)
|
|
|
|
|> text_body(text)
|
2019-09-17 02:45:32 +02:00
|
|
|
end
|
|
|
|
end
|