Documentation

Mail
in package

Class for preparing and handling email messages.

Table of Contents

Methods

addToQueue()  : bool
Add an email to the mail queue.
adminNotify()  : void
This simple function gets a list of all administrators and sends them an email to let them know a new member has joined.
loadEmailTemplate()  : array<string|int, mixed>
Load a template from EmailTemplates language file.
mimespecialchars()  : array<string|int, mixed>
Prepare text strings for sending as email body or header.
reduceQueue()  : bool
Send a group of emails from the mail queue.
send()  : bool
This function sends an email to the specified recipient(s).
sendNotifications()  : void
Sends a notification to members who have elected to receive emails when things happen to a topic, such as replies are posted.
userInfoCallback()  : string
Callback function for loadEmailTemplate on subject and body Uses capture group 1 in array

Methods

addToQueue()

Add an email to the mail queue.

public static addToQueue([bool $flush = false ][, array<string|int, mixed> $to_array = [] ][, string $subject = '' ][, string $message = '' ][, string $headers = '' ][, bool $send_html = false ][, int $priority = 3 ][, bool $is_private = false ]) : bool
Parameters
$flush : bool = false

Whether to flush the queue

$to_array : array<string|int, mixed> = []

An array of recipients

$subject : string = ''

The subject of the message

$message : string = ''

The message

$headers : string = ''

The headers

$send_html : bool = false

Whether to send in HTML format

$priority : int = 3

The priority

$is_private : bool = false

Whether this is private

Return values
bool

Whether the message was added

adminNotify()

This simple function gets a list of all administrators and sends them an email to let them know a new member has joined.

public static adminNotify(string $type, int $memberID[, string $member_name = null ]) : void

Called by registerMember() function in Subs-Members.php. Email is sent to all groups that have the moderate_forum permission. The language set by each member is being used (if available). Uses the Login language file

Parameters
$type : string

The type. Types supported are 'approval', 'activation', and 'standard'.

$memberID : int

The ID of the member

$member_name : string = null

The name of the member (if null, it is pulled from the database)

loadEmailTemplate()

Load a template from EmailTemplates language file.

public static loadEmailTemplate(string $template[, array<string|int, mixed> $replacements = [] ][, string $lang = '' ][, bool $loadLang = true ]) : array<string|int, mixed>
Parameters
$template : string

The name of the template to load

$replacements : array<string|int, mixed> = []

An array of replacements for the variables in the template

$lang : string = ''

The language to use, if different than the user's current language

$loadLang : bool = true

Whether to load the language file first

Return values
array<string|int, mixed>

An array containing the subject and body of the email template, with replacements made

mimespecialchars()

Prepare text strings for sending as email body or header.

public static mimespecialchars(string $string[, bool $with_charset = true ][, bool $hotmail_fix = false ][, string $line_break = " " ][, string $custom_charset = null ]) : array<string|int, mixed>

In case there are higher ASCII characters in the given string, this function will attempt the transport method 'quoted-printable'. Otherwise the transport method '7bit' is used.

Parameters
$string : string

The string

$with_charset : bool = true

Whether we're specifying a charset ($custom_charset must be set here)

$hotmail_fix : bool = false

Whether to apply the hotmail fix (all higher ASCII characters are converted to HTML entities to assure proper display of the mail)

$line_break : string = " "

The linebreak

$custom_charset : string = null

If set, it uses this character set

Return values
array<string|int, mixed>

An array containing the character set, the converted string and the transport method.

reduceQueue()

Send a group of emails from the mail queue.

public static reduceQueue([bool|int $number = false ][, bool $override_limit = false ][, bool $force_send = false ]) : bool
Parameters
$number : bool|int = false

The number to send each loop through or false to use the standard limits

$override_limit : bool = false

Whether to bypass the limit

$force_send : bool = false

Whether to forcibly send the messages now (useful when using cron jobs)

Return values
bool

Whether things were sent

send()

This function sends an email to the specified recipient(s).

public static send(array<string|int, mixed>|string $to, string $subject, string $message[, string $from = null ][, string $message_id = null ][, bool $send_html = false ][, int $priority = 3 ][, bool $hotmail_fix = null ][, bool $is_private = false ]) : bool

It uses the mail_type settings and webmaster_email variable.

Parameters
$to : array<string|int, mixed>|string

The email(s) to send to

$subject : string

Email subject, expected to have entities, and slashes, but not be parsed

$message : string

Email body, expected to have slashes, no htmlentities

$from : string = null

The address to use for replies

$message_id : string = null

If specified, it will be used as local part of the Message-ID header.

$send_html : bool = false

Whether or not the message is HTML vs. plain text

$priority : int = 3

The priority of the message

$hotmail_fix : bool = null

Whether to apply the "hotmail fix"

$is_private : bool = false

Whether this is private

Return values
bool

Whether ot not the email was sent properly.

sendNotifications()

Sends a notification to members who have elected to receive emails when things happen to a topic, such as replies are posted.

public static sendNotifications(int|array<string|int, mixed> $topics, string $type[, array<string|int, mixed> $exclude = [] ][, array<string|int, mixed> $members_only = [] ]) : void

The function automatically finds the subject and its board, and checks permissions for each member who is "signed up" for notifications. It will not send 'reply' notifications more than once in a row. Uses Post language file

Parameters
$topics : int|array<string|int, mixed>

Represents the topics the action is happening to.

$type : string

Can be any of reply, sticky, lock, unlock, remove, move, merge, and split. An appropriate message will be sent for each.

$exclude : array<string|int, mixed> = []

Members in the exclude array will not be processed for the topic with the same key.

$members_only : array<string|int, mixed> = []

Are the only ones that will be sent the notification if they have it on.

userInfoCallback()

Callback function for loadEmailTemplate on subject and body Uses capture group 1 in array

protected static userInfoCallback(array<string|int, mixed> $matches) : string
Parameters
$matches : array<string|int, mixed>

An array of matches

Return values
string

The match


        
On this page

Search results