Send email (POST /api/v1/json/bulk/email).
{:ok, result} =
Unicom360.Email.send(client, %{
from: "noreply@yourdomain.com",
to: ["jane@example.com", "john@example.com"],
subject: "Your order is confirmed",
email_body: "<p>Thanks for your order. Order ZM4821 is confirmed.</p>",
reply_to: "support@yourdomain.com"
})
jane = Unicom360.Email.SendResult.by_address(result, "jane@example.com")Email is never retried after the request may have reached the gateway, even with a
user_reference_id: the gateway's duplicate check for email is not atomic, so two
overlapping attempts could both be sent. It is retried only after a 429 and after a failure to
connect.
Summary
Functions
Sends an email to one or more addresses.
Like send/3, but returns the result or raises Unicom360.Error.
Types
@type params() :: %{ :from => String.t(), :to => String.t() | [String.t()], :subject => String.t(), :email_body => String.t(), optional(:reply_to) => String.t() | nil, optional(:user_reference_id) => String.t() | nil, optional(:callback_url) => String.t() | nil, optional(:source) => String.t() | nil } | keyword()
The email parameters, as a map or a keyword list:
:from(required) - a registered sender address.:to(required) - one address, or a list of addresses.:subject(required).:email_body(required) - HTML or plain text.:reply_to- the Reply-To address.:user_reference_id- your reference; the gateway refuses a later repeat of it (DUPLICATE_REFERENCE).:callback_url- where the gateway posts delivery reports (unsigned; seeUnicom360.Webhook.parse_email_callback/1).:source- a label for your reporting.
Functions
@spec send(Unicom360.Client.t(), params(), keyword()) :: {:ok, Unicom360.Email.SendResult.t()} | {:error, Unicom360.Error.t()}
Sends an email to one or more addresses.
Returns {:ok, %Unicom360.Email.SendResult{}}, one entry per recipient. An invalid address is
not an error: its entry's status is "Invalid email address". Results are not in request
order past the tenth recipient: find one with Unicom360.Email.SendResult.by_address/2.
Options: :timeout (ms per attempt) and :max_retries.
@spec send!(Unicom360.Client.t(), params(), keyword()) :: Unicom360.Email.SendResult.t()
Like send/3, but returns the result or raises Unicom360.Error.