ex_postmark v1.3.0 ExPostmark.Mailer
Defines a mailer.
A mailer is a wrapper around an adapter that makes it easy for you to swap the adapter without having to change your code.
It is also responsible for doing some sanity checks before handing down the email to the adapter.
When used, the mailer expects :otp_app
as an option.
The :otp_app
should point to an OTP application that has the mailer
configuration. For example, the mailer:
defmodule Sample.Mailer do
use ExPostmark.Mailer, otp_app: :sample
end
Could be configured with:
config :sample, Sample.Mailer,
adapter: ExPostmark.Adapters.Postmark,
api_key: "abc123"
Examples
Once configured you can use your mailer like this:
# in an IEx console
iex> email = new |> from("tony.stark@example.com") |> to("steve.rogers@example.com")
%ExPostmark.Email{from: {"", "tony.stark@example.com"}, ...}
iex> Mailer.deliver(email)
:ok
Summary
Functions
Parses the OTP configuration at compile time
Parses the OTP configuration at run time. This function will transform all the {:system, “ENV_VAR”} tuples into their respective values grabbed from the process environment