feat: allow text message
This commit is contained in:
@@ -36,18 +36,41 @@ defmodule Swoosh.Adapters.Mailinator do
|
||||
Don't use this adapter for confidential information.
|
||||
|
||||
Use for tests only.
|
||||
|
||||
TODO: allow to choose from Text or HTML :prefer_html, :prefer_text
|
||||
"""
|
||||
"""
|
||||
|
||||
use Swoosh.Adapter, required_config: []
|
||||
|
||||
alias Swoosh.Email
|
||||
alias Swoosh.Mailer
|
||||
|
||||
def deliver(%Email{} = email, _) do
|
||||
def deliver(%Email{html_body: html, text_body: text} = email, _) when is_nil(html) do
|
||||
email |> delegate
|
||||
end
|
||||
|
||||
def deliver(%Email{html_body: html, text_body: text} = email, _) when is_nil(text) do
|
||||
email |> delegate
|
||||
end
|
||||
|
||||
def deliver(%Email{html_body: _, text_body: _} = email, _) do
|
||||
email
|
||||
|> Map.put(:text_body, nil)
|
||||
|> delegate
|
||||
end
|
||||
|
||||
def deliver(%Email{text_body: _} = email, _) do
|
||||
email
|
||||
|> Map.put(:html_body, nil)
|
||||
|> delegate
|
||||
end
|
||||
|
||||
def deliver(%Email{html_body: _} = email, _) do
|
||||
email
|
||||
|> Map.put(:text_body, nil)
|
||||
|> delegate
|
||||
end
|
||||
|
||||
defp delegate(%Email{} = email) do
|
||||
email
|
||||
|> Mailer.deliver([
|
||||
adapter: Swoosh.Adapters.SMTP,
|
||||
relay: "mail.mailinator.com",
|
||||
|
Reference in New Issue
Block a user