Email
in package
Handles sending emails and registering email placeholders.
Tags
Table of Contents
Constants
- API_REGISTRATION = 4
- FORGOT_PASSWORD = 3
- FORUM_TOPIC_REPLY = 5
- MASS_MESSAGE = 6
- REGISTRATION = 1
Properties
- $_message_placeholders : array<string, string>
Methods
- addPlaceholder() : void
- Add a custom placeholder/variable for email messages.
- formatEmail() : string
- Format an email template and replace placeholders.
- getReplyTo() : array<string|int, mixed>
- Get reply to array for send().
- send() : bool|array<string|int, mixed>
- Send an email.
- sendMailer() : array<string|int, mixed>|bool
- Send an email using the PHPMailer library.
- sendPHP() : array<string|int, mixed>|bool
- Send an email using PHP's `mail()` function.
Constants
API_REGISTRATION
public
mixed
API_REGISTRATION
= 4
FORGOT_PASSWORD
public
mixed
FORGOT_PASSWORD
= 3
FORUM_TOPIC_REPLY
public
mixed
FORUM_TOPIC_REPLY
= 5
MASS_MESSAGE
public
mixed
MASS_MESSAGE
= 6
REGISTRATION
public
mixed
REGISTRATION
= 1
Properties
$_message_placeholders
private
static array<string, string>
$_message_placeholders
= []
Placeholders for email templates
Methods
addPlaceholder()
Add a custom placeholder/variable for email messages.
public
static addPlaceholder(string $key, string|callable(Language, string): string $value) : void
Parameters
- $key : string
-
The key to use for the placeholder, should be enclosed in square brackets.
- $value : string|callable(Language, string): string
-
The value to replace the placeholder with.
formatEmail()
Format an email template and replace placeholders.
public
static formatEmail(string $email, Language $viewing_language) : string
Parameters
- $email : string
-
Name of email to format.
- $viewing_language : Language
-
Instance of Language class to use for translations.
Return values
string —Formatted email.
getReplyTo()
Get reply to array for send().
public
static getReplyTo() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array with reply-to email address and name
send()
Send an email.
public
static send(array<string|int, mixed> $recipient, string $subject, string $message[, array<string|int, mixed>|null $reply_to = null ]) : bool|array<string|int, mixed>
Parameters
- $recipient : array<string|int, mixed>
-
Array containing
'email'
and'name'
strings for the recipient of the email. - $subject : string
-
Subject of the email.
- $message : string
-
Message of the email.
- $reply_to : array<string|int, mixed>|null = null
-
Array containing
'email'
and'name'
strings for the reply-to address, if not provided the default setting will be used.
Return values
bool|array<string|int, mixed> —Returns true if email sent, otherwise returns an array containing the error.
sendMailer()
Send an email using the PHPMailer library.
private
static sendMailer(array<string|int, mixed> $email) : array<string|int, mixed>|bool
Parameters
- $email : array<string|int, mixed>
-
Array of email data to send.
Tags
Return values
array<string|int, mixed>|bool —Returns true if email sent, otherwise returns an array containing the error.
sendPHP()
Send an email using PHP's `mail()` function.
private
static sendPHP(array<string|int, mixed> $email) : array<string|int, mixed>|bool
Parameters
- $email : array<string|int, mixed>
-
Array containing
to
,subject
,message
andheaders
values.
Return values
array<string|int, mixed>|bool —Returns true if email sent, otherwise returns an array containing the error.