pfeifferNet

HTML_Email extends Email
in package

Class to provide HTML email messages and settings.

Tags
since
1.0.0
5.5.0

Now inherits from Email class.

5.9.0

Improved base class to simplify this sub-class

uses
Email
used-by
User_Account

Table of Contents

Constants

EMAIL_CONTENT  : string = 'email-content-row.php'
Email body content row template.
EMAIL_FOOTER_EXTERNAL  : string = 'email-footer-external.php'
Email body footer template for external mail.
EMAIL_FOOTER_INTERNAL  : string = 'email-footer-internal.php'
Email body footer template for internal mail.
EMAIL_HEADER  : string = 'email-header.php'
Email body header template.
EMAIL_SIGNATURE  : string = 'email-signature.php'
Email body footer template.
MAIL_DEFAULTS  : mixed = array('to' => '', 'cc' => '', 'bcc' => '', 'sub...
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
since
5.3.1

Email body footer template for external mail.

protected string EMAIL_FOOTER_EXTERNAL = 'email-footer-external.php'
since
5.3.0

Email body footer template for internal mail.

protected string EMAIL_FOOTER_INTERNAL = 'email-footer-internal.php'
since
5.5.0

EMAIL_HEADER

Email body header template.

protected string EMAIL_HEADER = 'email-header.php'
Tags
since
5.3.0

EMAIL_SIGNATURE

Email body footer template.

protected string EMAIL_SIGNATURE = 'email-signature.php'
Tags
since
5.3.0

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
since
5.5.0
type

array MAIL_DEFAULTS { @type string $to The email address(es) of the intended recipient of the email. @type string $cc The copy recipients. @type string $bcc The blind copy recipients. @type string $subject The subject of the email. @type string $body The email message body. @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. }

Properties

$attachments

The email attachments.

protected array<string|int, string> $attachments = array()
Tags
since
1.0.0

$bcc

The bcc recipients of the email.

protected array<string|int, string> $bcc = array()
Tags
since
1.0.0

$cc

The cc recipients of the email.

protected array<string|int, string> $cc = array()
Tags
since
1.0.0

$email_content

The fully qualified path to the email body content table row partial.

protected string $email_content = ''
Tags
since
5.5.0

The fully qualified path to the external email footer partial.

protected string $email_footer_external = ''
since
5.3.0

The fully qualified path to the internal email footer partial.

protected string $email_footer_internal = ''
since
5.5.0

$email_header

The fully qualified path to the email body header partial.

protected string $email_header = ''
Tags
since
5.3.0

$email_signature

The fully qualified path to the email signature partial.

protected string $email_signature = ''
Tags
since
5.3.1

$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
since
5.9.0

$is_internal

The internal/external email flag.

protected bool $is_internal = false
Tags
since
5.9.0

$message

The email message.

protected string $message = ''
Tags
since
1.0.0

$subject

The subject of the email.

protected string $subject = ''
Tags
since
1.0.0

$to

The recipients of the email.

protected array<string|int, string> $to = array()
Tags
since
1.0.0

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
since
1.0.0

get_message()

Return the email message body.

public get_message() : string
Tags
since
5.6.0
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
since
5.9.0
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
since
1.0.0
Return values
bool|WP_Error

get_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
since
5.3.1
Return values
string —

The markup for an email content table row.

Get external email footer.

protected get_content_footer_external() : string
since
5.3.0
Return values
string —

The email footer HTML markup.

Get internal email footer

protected get_content_footer_internal() : string
since
5.5.0
Return values
string —

The email footer HTML markup.

get_content_header()

Get email content header.

protected get_content_header() : string
Tags
since
5.3.0
Return values
string —

The email header HTML markup.

get_content_signature()

Get email signature block.

protected get_content_signature() : string
Tags
since
5.3.1
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
since
1.0.0
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
since
1.0.0
Return values
void|WP_Error

set_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
since
1.0.0

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
since
1.0.0

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
since
1.0.0

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
since
1.0.0

set_message()

Set the message.

protected set_message(string $body) : void
Parameters
$body : string

The body content of the email.

Tags
since
5.5.0

set_partial_paths()

Set fully qualified paths to required partials.

protected set_partial_paths() : void
Tags
since
1.0.0

set_subject()

Set subject.

protected set_subject(string $subject) : void
Parameters
$subject : string

The subject of the email.

Tags
since
1.0.0

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.

Tags
since
1.0.0

        
On this page

Search results