function simplenews_mail in Simplenews 3.x
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.2 simplenews.module \simplenews_mail()
- 7 simplenews.module \simplenews_mail()
Implements hook_mail().
File
- ./
simplenews.module, line 556 - Simplenews node handling, sent email, newsletter block and general hooks.
Code
function simplenews_mail($key, &$message, $params) {
/** @var \Drupal\simplenews\Mail\MailBuilder $builder */
$builder = \Drupal::service('simplenews.mail_builder');
switch ($key) {
case 'node':
case 'test':
$builder
->buildNewsletterMail($message, $params['simplenews_mail']);
break;
case 'subscribe_combined':
$builder
->buildCombinedMail($message, $params);
break;
case 'validate':
$builder
->buildValidateMail($message, $params);
break;
default:
throw new \Exception("Unrecognised key {$key}");
}
// Debug message to check for outgoing emails messages.
// Debug message of node and test emails is set in simplenews_mail_mail().
$config = \Drupal::config('simplenews.settings');
if ($config
->get('mail.debug') && $key != 'node' && $key != 'test') {
\Drupal::logger('simplenews')
->debug('Outgoing email. Message type: %type<br />Subject: %subject<br />Recipient: %to', [
'%type' => $key,
'%to' => $message['to'],
'%subject' => $message['subject'],
]);
}
}