function simplenews_mail in Simplenews 7.2
Same name and namespace in other branches
- 8.2 simplenews.module \simplenews_mail()
- 8 simplenews.module \simplenews_mail()
- 6.2 simplenews.module \simplenews_mail()
- 6 simplenews.module \simplenews_mail()
- 7 simplenews.module \simplenews_mail()
- 3.x simplenews.module \simplenews_mail()
Implements hook_mail().
Send simplenews mails using drupal mail API.
Parameters
$key: Must be one of: node, test, subscribe, unsubscribe.
$message: The message array, containing at least the following keys:
- from
- headers: An array containing at least a 'From' key.
- language: The preferred message language.
array $params: The parameter array, containing the following keys:
- simplenews_source: An implementation of SimplenewsSourceInterface which provides the necessary information to build the newsletter mail.
@see drupal_mail()
File
- ./
simplenews.module, line 1905 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_mail($key, &$message, $params) {
module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
switch ($key) {
case 'node':
case 'test':
simplenews_build_newsletter_mail($message, $params['simplenews_source']);
break;
case 'subscribe':
simplenews_build_subscribe_mail($message, $params);
break;
break;
case 'subscribe_combined':
simplenews_build_combined_mail($message, $params);
break;
case 'unsubscribe':
simplenews_build_unsubscribe_mail($message, $params);
break;
}
// Debug message to check for outgoing emails messages.
// Debug message of node and test emails is set in simplenews_mail_mail().
if (variable_get('simplenews_debug', FALSE) && $key != 'node' && $key != 'test') {
watchdog('simplenews', 'Outgoing email. Message type: %type<br />Subject: %subject<br />Recipient: %to', array(
'%type' => $key,
'%to' => $message['to'],
'%subject' => $message['subject'],
), WATCHDOG_DEBUG);
}
}