z_email (zotonic_core v1.0.0-rc.17)
Send e-mail to a recipient. Optionally queue low priority messages.
Summary
Functions
Combine a name and an email address to the format jan janssen <jan@example.com> Uses the rfc822 formatting rules, so names with spaces or special characters are quoted.
If the recipient is an resource id, ensure that it is formatted as an email address.
Return the email address to be used in emails for the given id. The address will be formatted using the recipient's name.
Fetch the e-mail address of the site administrator. This is the email address for display purposes. The admin emails are not send to the wwwadmin_email, as that might not (yet) exist.
Fetch the default From e-mail address. Defaults to noreply@hostname
Send an email message defined by the email record.
Send a simple text message to an email address
Send a simple text message to the administrator
Send a page to an e-mail address, assumes the correct template "mailing_page.tpl" is available. Defaults for these pages are supplied by mod_mailinglist.
Send a html message to an email address, render the message using a template.
Send a html and text message to an email address, render the message using two templates.
Queue a simple text message to an email address
Queue a html message to an email address, render the message using a template.
Queue a html and text message to an email address, render the message using two templates.
Split the name and email from the format jan janssen <jan@example.com>. If just "jan" is given then it is assumed that the name is "" and the address is "jan". The email routines should add the default email domain to the returned email address if it is missing.
Functions
-spec combine_name_email(Name, Email) -> NameEmail when Name :: binary() | string() | undefined, Email :: binary() | string(), NameEmail :: binary().
Combine a name and an email address to the format jan janssen <jan@example.com> Uses the rfc822 formatting rules, so names with spaces or special characters are quoted.
-spec ensure_to_email(#email{to :: list() | string() | binary() | m_rsc:resource_id() | undefined, cc :: list() | string() | binary() | undefined, bcc :: list() | string() | binary() | undefined, from :: binary() | string(), reply_to :: binary() | string() | message_id | undefined, headers :: [{binary(), binary()}], body :: term(), raw :: term(), subject :: iodata() | undefined, text :: iodata() | undefined, html :: iodata() | undefined, text_tpl :: template_compiler:template() | undefined, html_tpl :: template_compiler:template() | undefined, vars :: list(), attachments :: list(), queue :: boolean()}, z:context()) -> {ok, #email{to :: list() | string() | binary() | m_rsc:resource_id() | undefined, cc :: list() | string() | binary() | undefined, bcc :: list() | string() | binary() | undefined, from :: binary() | string(), reply_to :: binary() | string() | message_id | undefined, headers :: [{binary(), binary()}], body :: term(), raw :: term(), subject :: iodata() | undefined, text :: iodata() | undefined, html :: iodata() | undefined, text_tpl :: template_compiler:template() | undefined, html_tpl :: template_compiler:template() | undefined, vars :: list(), attachments :: list(), queue :: boolean()}} | {error, term()}.
If the recipient is an resource id, ensure that it is formatted as an email address.
-spec format_recipient(RecipientId, Context) -> {ok, EmailAddress} | {error, Reason} when RecipientId :: m_rsc:resource(), Context :: z:context(), EmailAddress :: binary(), Reason :: enoent | no_email | eacces.
Return the email address to be used in emails for the given id. The address will be formatted using the recipient's name.
Fetch the e-mail address of the site administrator. This is the email address for display purposes. The admin emails are not send to the wwwadmin_email, as that might not (yet) exist.
Fetch the default From e-mail address. Defaults to noreply@hostname
Send an email message defined by the email record.
Send a simple text message to an email address
Send a simple text message to the administrator
Send a page to an e-mail address, assumes the correct template "mailing_page.tpl" is available. Defaults for these pages are supplied by mod_mailinglist.
Send a html message to an email address, render the message using a template.
Send a html and text message to an email address, render the message using two templates.
Queue a simple text message to an email address
Queue a html message to an email address, render the message using a template.
Queue a html and text message to an email address, render the message using two templates.
-spec split_name_email(String) -> {Name, Email} when String :: string() | binary(), Name :: binary(), Email :: binary().
Split the name and email from the format jan janssen <jan@example.com>. If just "jan" is given then it is assumed that the name is "" and the address is "jan". The email routines should add the default email domain to the returned email address if it is missing.