function simple_mail_queue in Simple Mail 7
Same name and namespace in other branches
- 8 simple_mail.module \simple_mail_queue()
- 2.0.x simple_mail.module \simple_mail_queue()
Queue an email to be sent via the Queue API during cron runs.
Queues an email for sending through Drupal's Queue API, rather than sending immediately. This function is basically a queued version of the nearly- identical function simple_mail_send_email(). Use this function when sending batches of email so the page request is not delayed while waiting for individual messages to be sent.
Parameters
(string) $from: Email sender. Defaults to the system email.
(string) $to: Email receipient.
(string) $subject: Email subject.
(string) $body: Email message body (can be HTML or plaintext).
Return value
bool TRUE if the email was queued, FALSE otherwise.
See also
File
- ./
simple_mail.module, line 130 - Simple Mail module.
Code
function simple_mail_queue($from, $to, $subject, $body) {
// If the queue is disabled, return FALSE.
if (!variable_get('simple_mail_queue_enabled', 0)) {
return FALSE;
}
// Queue the email.
$queue = DrupalQueue::get('SimpleMailQueue', TRUE);
$item = array(
'from' => $from,
'to' => $to,
'subject' => $subject,
'body' => $body,
);
$queue
->createItem($item);
return TRUE;
}