public function MailBuilder::buildUnsubscribeMail in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Mail/MailBuilder.php \Drupal\simplenews\Mail\MailBuilder::buildUnsubscribeMail()
Build subject and body of the unsubscribe confirmation email.
Parameters
array $message: Message array as used by hook_mail().
array $params: Parameter array as used by hook_mail().
Overrides MailBuilderInterface::buildUnsubscribeMail
File
- src/
Mail/ MailBuilder.php, line 147
Class
- MailBuilder
- Default mail builder.
Namespace
Drupal\simplenews\MailCode
public function buildUnsubscribeMail(array &$message, array $params) {
$context = $params['context'];
// Use formatted from address "name" <mail_address>.
$message['headers']['From'] = $params['from']['formatted'];
$message['subject'] = $this->config
->get('subscription.confirm_subscribe_subject');
$message['subject'] = $this->token
->replace($message['subject'], $context, [
'sanitize' => FALSE,
]);
if ($context['simplenews_subscriber']
->isSubscribed($context['newsletter']
->id())) {
$body = $this->config
->get('subscription.confirm_unsubscribe_subscribed');
$message['body'][] = $this->token
->replace($body, $context, [
'sanitize' => FALSE,
]);
}
else {
$body = $this->config
->get('subscription.confirm_unsubscribe_unsubscribed');
$message['body'][] = $this->token
->replace($body, $context, [
'sanitize' => FALSE,
]);
}
}