class vB_Mail_Queue extends vB_Mail

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.

Traits

Properties

protected string $toemail Destination address from vB_Mail
protected string $subject Subject from vB_Mail
protected string $message Message from vB_Mail
protected string $headers All headers to be sent with the message from vB_Mail
protected string $fromemail Sender email from vB_Mail
protected string $delimiter Line delimiter from vB_Mail
protected boolean $debug Switch to enable/disable debugging. When enabled, warnings are not suppressed from vB_Mail
protected string $log Message to log if logging is enabled from vB_Mail
static protected boolean $enableTestCapture Used for unit tests. fetchLibrary() will return the test stub if this is set to true. from vB_Mail
protected array $shortcode_replace_map Array of phrase shortcode replacements from vB_Mail
protected array $mailsql The data to insert into the mail queue
protected string $mailcounter The number of mails being inserted into the queue
protected boolean $bulk Whether to do bulk inserts into the database.

Methods

__sleep()

No description

__wakeup()

No description

static bool
vbmail(string $toemail, string $subject, string $message, boolean $sendnow = false, string $from = '', string $uheaders = '', string $username = '', bool $skipFloodCheck = false, string $contentType = 'text/plain')

Starts the process of sending an email - either immediately or by adding it to the mail queue.

from vB_Mail
static 
vbmailStart()

Begin adding email to the mail queue

from vB_Mail
static 
vbmailEnd()

Stop adding mail to the mail queue and insert the mailqueue data for sending later

from vB_Mail
static 
execMailQueue()

Reads the email message queue and delivers a number of pending emails to the message sender

from vB_Mail
__construct()

Constructor

static vB_Mail
fetchLibrary(bool $deferred = false)

Factory method for mail.

from vB_Mail
bool
start(string $toemail, string $subject, string $message, string $from = '', string $uheaders = '', string $username = '', string $contentType = 'text/plain')

Starts the process of sending an email - preps it so it's fully ready to send.

from vB_Mail
quickSet(string $toemail, string $subject, string $message, string $headers, string $fromemail)

Set all the necessary variables for sending a message.

from vB_Mail
boolean
send(bool $force_send = false)

Send the mail.

from vB_Mail
boolean
execSend()

Inserts the message into the queue instead of sending it.

doShortcodeReplacements()

Does the phrase shortcode replacements for emails.

from vB_Mail
string
fetchFirstLine(string $text)

Returns the first line of a string -- good to prevent errors when sending emails (above)

from vB_Mail
string
encodeEmailHeader(string $text, string $charset = 'utf-8', bool $force_encode = false, bool $quoted_string = true)

Encodes a mail header to be RFC 2047 compliant. This allows for support of non-ASCII character sets via the quoted-printable encoding.

from vB_Mail
setDebug($debug)

Sets the debug member

from vB_Mail
logEmail(bool $status = true, bool $errfile = false)

Logs email to file

from vB_Mail
static 
emailFloodCheck()

No description

from vB_Mail
static 
setTestMode($enable = false)

No description

from vB_Mail
static 
getTestMode()

No description

from vB_Mail
arraySize($a)

No description

setBulk(boolean $bulk)

Sets the bulk option. If disabling the option, this also flushes the cache into the database.

static vB_QueueMail
fetchInstance()

Singleton emulator. Fetches the instance if it doesn't exist.

execQueue()

The only part of this class which actually sends an email.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

in vB_Mail at line 116
static bool vbmail(string $toemail, string $subject, string $message, boolean $sendnow = false, string $from = '', string $uheaders = '', string $username = '', bool $skipFloodCheck = false, string $contentType = 'text/plain')

Starts the process of sending an email - either immediately or by adding it to the mail queue.

Parameters

string $toemail Destination email address
string $subject Email message subject
string $message Email message body
boolean $sendnow If true, do not use the mail queue and send immediately
string $from Optional name/email to use in 'From' header
string $uheaders Additional headers
string $username Username of person sending the email
bool $skipFloodCheck If true, the flood check will be skipped
string $contentType Content type for email.

Return Value

bool

in vB_Mail at line 152
static vbmailStart()

Begin adding email to the mail queue

in vB_Mail at line 161
static vbmailEnd()

Stop adding mail to the mail queue and insert the mailqueue data for sending later

in vB_Mail at line 170
static execMailQueue()

Reads the email message queue and delivers a number of pending emails to the message sender

at line 47
protected __construct()

Constructor

in vB_Mail at line 208
static vB_Mail fetchLibrary(bool $deferred = false)

Factory method for mail.

Parameters

bool $deferred Whether mail sending can be deferred

Return Value

vB_Mail

in vB_Mail at line 241
bool start(string $toemail, string $subject, string $message, string $from = '', string $uheaders = '', string $username = '', string $contentType = 'text/plain')

Starts the process of sending an email - preps it so it's fully ready to send.

Call send() to actually send it.

Parameters

string $toemail Destination email address
string $subject Email message subject
string $message Email message body
string $from Optional name/email to use in 'From' header
string $uheaders Additional headers
string $username Username of person sending the email
string $contentType Encoding for mail.

Return Value

bool True on success, false on failure

in vB_Mail at line 378
quickSet(string $toemail, string $subject, string $message, string $headers, string $fromemail)

Set all the necessary variables for sending a message.

Parameters

string $toemail Destination address
string $subject Subject
string $message Message
string $headers All headers to be sent with the message
string $fromemail Sender email

in vB_Mail at line 398
boolean send(bool $force_send = false)

Send the mail.

Note: If you define DISABLE_MAIL in config.php as: delimited email addresses - Only mail for the recipients will be sent .log - Mail will be logged to the given file if writable any other value - Mail will be disabled

Parameters

bool $force_send If true, DISABLE_MAIL will be ignored.

Return Value

boolean True on success, false on failure

at line 63
protected boolean execSend()

Inserts the message into the queue instead of sending it.

Return Value

boolean True on success, false on failure

in vB_Mail at line 493
protected doShortcodeReplacements()

Does the phrase shortcode replacements for emails.

in vB_Mail at line 547
protected string fetchFirstLine(string $text)

Returns the first line of a string -- good to prevent errors when sending emails (above)

Parameters

string $text String to be trimmed

Return Value

string

in vB_Mail at line 570
protected string encodeEmailHeader(string $text, string $charset = 'utf-8', bool $force_encode = false, bool $quoted_string = true)

Encodes a mail header to be RFC 2047 compliant. This allows for support of non-ASCII character sets via the quoted-printable encoding.

Parameters

string $text The text to encode
string $charset The character set of the text
bool $force_encode Whether to force encoding into quoted-printable even if not necessary
bool $quoted_string Whether to quote the string; applies only if encoding is not done

Return Value

string The encoded header

in vB_Mail at line 633
setDebug($debug)

Sets the debug member

Parameters

$debug boolean

in vB_Mail at line 646
protected logEmail(bool $status = true, bool $errfile = false)

Logs email to file

Parameters

bool $status
bool $errfile

in vB_Mail at line 707
static emailFloodCheck()

in vB_Mail at line 732
static setTestMode($enable = false)

Parameters

$enable

in vB_Mail at line 737
static getTestMode()

at line 108
protected arraySize($a)

Parameters

$a

at line 124
setBulk(boolean $bulk)

Sets the bulk option. If disabling the option, this also flushes the cache into the database.

Parameters

boolean $bulk

at line 163
static vB_QueueMail fetchInstance()

Singleton emulator. Fetches the instance if it doesn't exist.

Be sure to accept a reference if using this function!

Return Value

vB_QueueMail Reference to the instance

at line 179
execQueue()

The only part of this class which actually sends an email.

Sends mail from the queue.