vB_Mail_Queue
extends vB_Mail
in package
Mail queueing class. This class should be accessed as a singleton via fetchInstance()! This class does not actually send emails, but rather queues them to be sent later in a batch.
Tags
Table of Contents
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- emailFloodCheck() : mixed
- encodeForHeader() : string
- Escape text for inclusion in an email header.
- execMailQueue() : mixed
- Reads the email message queue and delivers a number of pending emails to the message sender
- execQueue() : mixed
- The only part of this class which actually sends an email.
- fetchInstance() : vB_QueueMail
- Singleton emulator. Fetches the instance if it doesn't exist.
- fetchLibrary() : vB_Mail
- Factory method for mail.
- getPostTextForEmail() : string
- Escape node rawtext and convert linebreaks to br tags for HTML emails
- getPreviewTextForEmail() : string
- Generate node preview text for HTML emails. Note that HTML in the original rawtext is escaped as part part of generating the preview text. Meant to be used together with wrapPreviewTextForEmail(). Split up because this can be cached for multiple recipients.
- getTestMode() : mixed
- getWrappedPreviewTextForEmail() : string
- Equivalent to calling vB_Mail::wrapPreviewTextForEmail(getPreviewTextForEmail(...),...) . Meant for single-recipient emails only
- quickSet() : mixed
- Set all the necessary variables for sending a message.
- send() : bool
- Send the mail.
- setBulk() : mixed
- Sets the bulk option. If disabling the option, this also flushes the cache into the database.
- setDebug() : mixed
- Sets the debug member
- setTestMode() : mixed
- start() : bool
- Starts the process of sending an email - preps it so it's fully ready to send.
- start2() : bool
- Starts the process of sending an email - preps it so it's fully ready to send.
- vbmail() : bool
- Starts the process of sending an email - either immediately or by adding it to the mail queue.
- vbmail2() : bool
- Starts the process of sending an email - either immediately or by adding it to the mail queue.
- vbmailEnd() : mixed
- Stop adding mail to the mail queue and insert the mailqueue data for sending later
- vbmailStart() : mixed
- Begin adding email to the mail queue
- wrapPreviewTextForEmail() : string
- Generate node preview text for HTML emails. Note that HTML in the original rawtext is escaped as part part of generating the preview text. Meant to be used together with getPreviewTextForEmail(). Split up because this cannot be cached for multiple recipients, as it depends on languageid.
Methods
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
public
__unserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
__wakeup()
public
__wakeup() : void
emailFloodCheck()
public
static emailFloodCheck() : mixed
encodeForHeader()
Escape text for inclusion in an email header.
public
static encodeForHeader(string $text) : string
Parameters
- $text : string
Return values
string —Escaped header fragment
execMailQueue()
Reads the email message queue and delivers a number of pending emails to the message sender
public
static execMailQueue() : mixed
execQueue()
The only part of this class which actually sends an email.
public
execQueue() : mixed
Sends mail from the queue.
fetchInstance()
Singleton emulator. Fetches the instance if it doesn't exist.
public
static fetchInstance() : vB_QueueMail
Be sure to accept a reference if using this function!
Return values
vB_QueueMail —Reference to the instance
fetchLibrary()
Factory method for mail.
public
static fetchLibrary([bool $deferred = false ]) : vB_Mail
Parameters
- $deferred : bool = false
-
Whether mail sending can be deferred
Return values
vB_MailgetPostTextForEmail()
Escape node rawtext and convert linebreaks to br tags for HTML emails
public
static getPostTextForEmail(string $rawtext, string $htmlstate, vB_Utility_String $stringUtil) : string
Parameters
- $rawtext : string
- $htmlstate : string
- $stringUtil : vB_Utility_String
Return values
stringgetPreviewTextForEmail()
Generate node preview text for HTML emails. Note that HTML in the original rawtext is escaped as part part of generating the preview text. Meant to be used together with wrapPreviewTextForEmail(). Split up because this can be cached for multiple recipients.
public
static getPreviewTextForEmail(string $rawtext, string $htmlstate, vB_Utility_String $stringUtil) : string
Parameters
- $rawtext : string
- $htmlstate : string
- $stringUtil : vB_Utility_String
Return values
stringgetTestMode()
public
static getTestMode() : mixed
getWrappedPreviewTextForEmail()
Equivalent to calling vB_Mail::wrapPreviewTextForEmail(getPreviewTextForEmail(...),...) . Meant for single-recipient emails only
public
static getWrappedPreviewTextForEmail(string $rawtext, string $htmlstate, vB_Utility_String $stringUtil, int $languageid) : string
Parameters
- $rawtext : string
- $htmlstate : string
- $stringUtil : vB_Utility_String
- $languageid : int
Return values
stringquickSet()
Set all the necessary variables for sending a message.
public
quickSet(string $toemail, string $subject, string $message, string $headers, string $fromemail) : mixed
Parameters
- $toemail : string
-
Destination address
- $subject : string
-
Subject
- $message : string
-
Message
- $headers : string
-
All headers to be sent with the message
- $fromemail : string
-
Sender email
send()
Send the mail.
public
send([bool $force_send = false ]) : bool
Note: If you define DISABLE_MAIL in config.php as:
delimited email addresses - Only mail for the recipients will be sent
Parameters
- $force_send : bool = false
-
If true, DISABLE_MAIL will be ignored.
Return values
bool —True on success, false on failure
setBulk()
Sets the bulk option. If disabling the option, this also flushes the cache into the database.
public
setBulk(bool $bulk) : mixed
Parameters
- $bulk : bool
setDebug()
Sets the debug member
public
setDebug( $debug) : mixed
Parameters
setTestMode()
public
static setTestMode([mixed $enable = false ]) : mixed
Parameters
- $enable : mixed = false
start()
Starts the process of sending an email - preps it so it's fully ready to send.
public
start(string $toemail, string $subject, string $message[, string $from = '' ][, string $uheaders = '' ][, string $username = '' ][, string $contentType = 'text/plain' ]) : bool
Call send() to actually send it.
Parameters
- $toemail : string
-
Destination email address
- $subject : string
-
Email message subject
- $message : string
-
Email message body
- $from : string = ''
-
Optional name/email to use in 'From' header
- $uheaders : string = ''
-
Additional headers
- $username : string = ''
-
Username of person sending the email
- $contentType : string = 'text/plain'
-
Encoding for mail.
Tags
Return values
bool —True on success, false on failure
start2()
Starts the process of sending an email - preps it so it's fully ready to send.
public
start2(string $toemail, string $subject, string $message[, string $from = '' ][, string $uheaders = '' ][, string $username = '' ][, string $contentType = 'text/html' ]) : bool
Call send() to actually send it.
Parameters
- $toemail : string
-
Destination email address
- $subject : string
-
Email message subject
- $message : string
-
Email message body
- $from : string = ''
-
Optional name/email to use in 'From' header
- $uheaders : string = ''
-
Additional headers
- $username : string = ''
-
Username of person sending the email
- $contentType : string = 'text/html'
-
Encoding for mail.
Return values
bool —True on success, false on failure
vbmail()
Starts the process of sending an email - either immediately or by adding it to the mail queue.
public
static vbmail(string $toemail, string $subject, string $message[, bool $sendnow = false ][, string $from = '' ][, string $uheaders = '' ][, string $username = '' ][, bool $skipFloodCheck = false ][, string $contentType = 'text/plain' ]) : bool
Parameters
- $toemail : string
-
Destination email address
- $subject : string
-
Email message subject
- $message : string
-
Email message body
- $sendnow : bool = false
-
If true, do not use the mail queue and send immediately
- $from : string = ''
-
Optional name/email to use in 'From' header
- $uheaders : string = ''
-
Additional headers
- $username : string = ''
-
Username of person sending the email
- $skipFloodCheck : bool = false
-
If true, the flood check will be skipped
- $contentType : string = 'text/plain'
-
Content type for email.
Tags
Return values
boolvbmail2()
Starts the process of sending an email - either immediately or by adding it to the mail queue.
public
static vbmail2(string $toemail, string $subject, string $message[, bool $sendnow = false ][, string $from = '' ][, string $uheaders = '' ][, string $username = '' ][, bool $skipFloodCheck = false ][, string $contentType = 'text/html' ]) : bool
Parameters
- $toemail : string
-
Destination email address
- $subject : string
-
Email message subject
- $message : string
-
Email message body
- $sendnow : bool = false
-
If true, do not use the mail queue and send immediately
- $from : string = ''
-
Optional name/email to use in 'From' header
- $uheaders : string = ''
-
Additional headers
- $username : string = ''
-
Username of person sending the email
- $skipFloodCheck : bool = false
-
If true, the flood check will be skipped
- $contentType : string = 'text/html'
-
Content type for email.
Return values
boolvbmailEnd()
Stop adding mail to the mail queue and insert the mailqueue data for sending later
public
static vbmailEnd() : mixed
vbmailStart()
Begin adding email to the mail queue
public
static vbmailStart() : mixed
wrapPreviewTextForEmail()
Generate node preview text for HTML emails. Note that HTML in the original rawtext is escaped as part part of generating the preview text. Meant to be used together with getPreviewTextForEmail(). Split up because this cannot be cached for multiple recipients, as it depends on languageid.
public
static wrapPreviewTextForEmail(string $previewtext, int $languageid) : string
Parameters
- $previewtext : string
-
from vB_Mail::getPreviewTextForEmail()
- $languageid : int
-
email recipient's languageid
Return values
string —Post snippet wrapped with the appropriate prefix based on emailpreview setting