63 lines
1.4 KiB
Elixir
63 lines
1.4 KiB
Elixir
defmodule Swoosh.Adapters.Mailinator do
|
|
|
|
@moduledoc ~S"""
|
|
An adapter that sends email to Mailinator.com service using the SMTP protocol.
|
|
|
|
Underneath this adapter uses the
|
|
[gen_smtp](https://github.com/gen-smtp/gen_smtp) library, add it to your mix.exs file.
|
|
|
|
## Example
|
|
|
|
# mix.exs
|
|
def deps do
|
|
[
|
|
{:swoosh, "~> 1.3"},
|
|
{:gen_smtp, "~> 1.1"}
|
|
]
|
|
end
|
|
|
|
# config/config.exs
|
|
config :sample, Sample.Mailer,
|
|
adapter: Swoosh.Adapters.Mailinator
|
|
|
|
# lib/sample/mailer.ex
|
|
defmodule Sample.Mailer do
|
|
use Swoosh.Mailer, otp_app: :sample
|
|
end
|
|
|
|
## Note
|
|
|
|
This adatper relay the email to the Mailinator.com SMTP server, no mater the internet domain of the recipient.
|
|
|
|
This service provide no encryption in transit (SSL/TLS) nor authentication.
|
|
|
|
This service provide public access to mailboxes.
|
|
|
|
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
|
|
email
|
|
|> IO.inspect()
|
|
|> Map.put(:text_body, nil)
|
|
|> Mailer.deliver([
|
|
adapter: Swoosh.Adapters.SMTP,
|
|
relay: "mail.mailinator.com",
|
|
port: 25,
|
|
tls: :never,
|
|
auth: :never,
|
|
retries: 1,
|
|
no_mx_lookups: true
|
|
])
|
|
end
|
|
end
|