HTML_Email
extends Email
in package
Class to provide HTML email messages and settings.
Tags
Table of Contents
Constants
- EMAIL_CONTENT = 'email-content-row.php'
- Email body content row template.
- EMAIL_FOOTER_EXTERNAL = 'email-footer-external.php'
- Email body footer template for external mail.
- EMAIL_FOOTER_INTERNAL = 'email-footer-internal.php'
- Email body footer template for internal mail.
- EMAIL_HEADER = 'email-header.php'
- Email body header template.
- EMAIL_SIGNATURE = 'email-signature.php'
- Email body footer template.
- MAIL_DEFAULTS = array('to' => '', 'cc' => '', 'bcc' => '', 'subject' => 'email', 'body' => '', 'headers' => array(), 'attachments' => array(), 'is_internal' => false)
- The array of default arguments for the email.
Properties
- $attachments : array<string|int, string>
- The email attachments.
- $bcc : array<string|int, string>
- The bcc recipients of the email.
- $cc : array<string|int, string>
- The cc recipients of the email.
- $email_content : string
- The fully qualified path to the email body content table row partial.
- $email_footer_external : string
- The fully qualified path to the external email footer partial.
- $email_footer_internal : string
- The fully qualified path to the internal email footer partial.
- $email_header : string
- The fully qualified path to the email body header partial.
- $email_signature : string
- The fully qualified path to the email signature partial.
- $headers : array<string|int, string>
- The email headers.
- $is_internal : bool
- The internal/external email flag.
- $message : string
- The email message.
- $subject : string
- The subject of the email.
- $to : array<string|int, string>
- The recipients of the email.
Methods
- __construct() : void
- Initialise the class and set its properties.
- get_message() : string
- Return the email message body.
- get_parameters() : array<string|int, mixed>
- Return the complete email parameters.
- send() : bool|WP_Error
- Checks for minimum requirements then sends the email.
- get_content_body() : string
- Get email content table row markup.
- get_content_footer_external() : string
- Get external email footer.
- get_content_footer_internal() : string
- Get internal email footer
- get_content_header() : string
- Get email content header.
- get_content_signature() : string
- Get email signature block.
- sanitise_email_array() : array<string|int, mixed>
- Sanitise an array of email addresses.
- set_attachments() : void|WP_Error
- Attach a file or array of files.
- set_bcc() : void
- Set bcc recipients.
- set_cc() : void
- Set cc recipients.
- set_headers() : void
- Set the email headers.
- set_is_internal() : void
- Set internal/external email flag.
- set_message() : void
- Set the message.
- set_partial_paths() : void
- Set fully qualified paths to required partials.
- set_subject() : void
- Set subject.
- set_to() : void
- Set recipients.
Constants
EMAIL_CONTENT
Email body content row template.
protected
string
EMAIL_CONTENT
= 'email-content-row.php'
Tags
EMAIL_FOOTER_EXTERNAL
Email body footer template for external mail.
protected
string
EMAIL_FOOTER_EXTERNAL
= 'email-footer-external.php'
Tags
EMAIL_FOOTER_INTERNAL
Email body footer template for internal mail.
protected
string
EMAIL_FOOTER_INTERNAL
= 'email-footer-internal.php'
Tags
EMAIL_HEADER
Email body header template.
protected
string
EMAIL_HEADER
= 'email-header.php'
Tags
EMAIL_SIGNATURE
Email body footer template.
protected
string
EMAIL_SIGNATURE
= 'email-signature.php'
Tags
MAIL_DEFAULTS
The array of default arguments for the email.
protected
mixed
MAIL_DEFAULTS
= array('to' => '', 'cc' => '', 'bcc' => '', 'subject' => 'email', 'body' => '', 'headers' => array(), 'attachments' => array(), 'is_internal' => false)
Tags
Properties
$attachments
The email attachments.
protected
array<string|int, string>
$attachments
= array()
Tags
$bcc
The bcc recipients of the email.
protected
array<string|int, string>
$bcc
= array()
Tags
$cc
The cc recipients of the email.
protected
array<string|int, string>
$cc
= array()
Tags
$email_content
The fully qualified path to the email body content table row partial.
protected
string
$email_content
= ''
Tags
$email_footer_external
The fully qualified path to the external email footer partial.
protected
string
$email_footer_external
= ''
Tags
$email_footer_internal
The fully qualified path to the internal email footer partial.
protected
string
$email_footer_internal
= ''
Tags
$email_header
The fully qualified path to the email body header partial.
protected
string
$email_header
= ''
Tags
$email_signature
The fully qualified path to the email signature partial.
protected
string
$email_signature
= ''
Tags
$headers
The email headers.
protected
array<string|int, string>
$headers
= array('Content-Type: text/html; charset=UTF-8')
This overides parent class and sets HTML email type.
Tags
$is_internal
The internal/external email flag.
protected
bool
$is_internal
= false
Tags
$message
The email message.
protected
string
$message
= ''
Tags
$subject
The subject of the email.
protected
string
$subject
= ''
Tags
$to
The recipients of the email.
protected
array<string|int, string>
$to
= array()
Tags
Methods
__construct()
Initialise the class and set its properties.
public
__construct(array<string|int, mixed> $args) : void
Parameters
- $args : array<string|int, mixed>
-
{ Array of email arguments. @type string|array $to The intended recipients. @type string|array $cc The copy recipients. @type string|array $bcc The blind copy recipients. @type string $subject The subject of the email. @type string $body The body content of the email. @type array $headers The email headers. @type array $attachments The files to attach to the email. @type bool $is_internal Flag to indicate that email is internal and not intended for external users. }
Tags
get_message()
Return the email message body.
public
get_message() : string
Tags
Return values
string —The email message body.
get_parameters()
Return the complete email parameters.
public
get_parameters() : array<string|int, mixed>
This inludes all the fields necessary for wp_mail.
Tags
Return values
array<string|int, mixed> —The email parameters .
send()
Checks for minimum requirements then sends the email.
public
send() : bool|WP_Error
Requires the email to have:
- recipient addresses(es).
- a subject.
- a message body
Tags
Return values
bool|WP_Errorget_content_body()
Get email content table row markup.
protected
get_content_body(string $content) : string
Parameters
- $content : string
-
The content to use in the email content table row.
Tags
Return values
string —The markup for an email content table row.
get_content_footer_external()
Get external email footer.
protected
get_content_footer_external() : string
Tags
Return values
string —The email footer HTML markup.
get_content_footer_internal()
Get internal email footer
protected
get_content_footer_internal() : string
Tags
Return values
string —The email footer HTML markup.
get_content_header()
Get email content header.
protected
get_content_header() : string
Tags
Return values
string —The email header HTML markup.
get_content_signature()
Get email signature block.
protected
get_content_signature() : string
Tags
Return values
string —The email signature HTML markup.
sanitise_email_array()
Sanitise an array of email addresses.
protected
sanitise_email_array(array<string|int, mixed> $addresses) : array<string|int, mixed>
Parameters
- $addresses : array<string|int, mixed>
-
An array of email addresses.
Tags
Return values
array<string|int, mixed> —Cleaned email addresses.
set_attachments()
Attach a file or array of files.
protected
set_attachments(array<string|int, mixed> $attachments) : void|WP_Error
Parameters
- $attachments : array<string|int, mixed>
-
The absolute path(s) to the attachments to include with the email.
Tags
Return values
void|WP_Errorset_bcc()
Set bcc recipients.
protected
set_bcc(string|array<string|int, mixed> $bcc) : void
Parameters
- $bcc : string|array<string|int, mixed>
-
Intended bcc recipients of the email.
Tags
set_cc()
Set cc recipients.
protected
set_cc(string|array<string|int, mixed> $cc) : void
Parameters
- $cc : string|array<string|int, mixed>
-
Intended cc recipients of the email.
Tags
set_headers()
Set the email headers.
protected
set_headers(array<string|int, mixed> $headers) : void
Parameters
- $headers : array<string|int, mixed>
-
The email headers.
Tags
set_is_internal()
Set internal/external email flag.
protected
set_is_internal(bool $is_internal) : void
Parameters
- $is_internal : bool
-
Flag to set internal/external email recipients.
Tags
set_message()
Set the message.
protected
set_message(string $body) : void
Parameters
- $body : string
-
The body content of the email.
Tags
set_partial_paths()
Set fully qualified paths to required partials.
protected
set_partial_paths() : void
Tags
set_subject()
Set subject.
protected
set_subject(string $subject) : void
Parameters
- $subject : string
-
The subject of the email.
Tags
set_to()
Set recipients.
protected
set_to(string|array<string|int, mixed> $to) : void
Parameters
- $to : string|array<string|int, mixed>
-
Intended recipients of the email.