function simplenews_send_source in Simplenews 7
Same name and namespace in other branches
- 7.2 includes/simplenews.mail.inc \simplenews_send_source()
Send a node to an email address.
Parameters
$source: The source object.s
Return value
boolean TRUE if the email was successfully delivered; otherwise FALSE.
Related topics
3 calls to simplenews_send_source()
- SimplenewsSourceTestCase::testSendMinimalSourceImplementation in tests/
simplenews.test - Tests that sending a minimal implementation of the source interface works.
- simplenews_mail_spool in includes/
simplenews.mail.inc - Send simplenews newsletters from the spool.
- simplenews_send_test in includes/
simplenews.mail.inc - Send test version of newsletter.
File
- includes/
simplenews.mail.inc, line 161 - Simplenews email send and spool handling
Code
function simplenews_send_source(SimplenewsSourceInterface $source) {
$params['simplenews_source'] = $source;
// Send mail.
$message = drupal_mail('simplenews', $source
->getKey(), $source
->getRecipient(), $source
->getLanguage(), $params, $source
->getFromFormatted());
// Log sent result in watchdog.
if (variable_get('simplenews_debug', FALSE)) {
if ($message['result']) {
watchdog('simplenews', 'Outgoing email. Message type: %type<br />Subject: %subject<br />Recipient: %to', array(
'%type' => $source
->getKey(),
'%to' => $message['to'],
'%subject' => $message['subject'],
), WATCHDOG_DEBUG);
}
else {
watchdog('simplenews', 'Outgoing email failed. Message type: %type<br />Subject: %subject<br />Recipient: %to', array(
'%type' => $source
->getKey(),
'%to' => $message['to'],
'%subject' => $message['subject'],
), WATCHDOG_ERROR);
}
}
// Build array of sent results for spool table and reporting.
if ($message['result']) {
$result = array(
'status' => SIMPLENEWS_SPOOL_DONE,
'error' => FALSE,
);
}
else {
// This error may be caused by faulty mailserver configuration or overload.
// Mark "pending" to keep trying.
$result = array(
'status' => SIMPLENEWS_SPOOL_PENDING,
'error' => TRUE,
);
}
return $result;
}