public function MailBuilder::buildSubscribeMail in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Mail/MailBuilder.php \Drupal\simplenews\Mail\MailBuilder::buildSubscribeMail()
Build subject and body of the subscribe confirmation email.
Parameters
array $message: Message array as used by hook_mail().
array $params: Parameter array as used by hook_mail().
Overrides MailBuilderInterface::buildSubscribeMail
File
- src/
Mail/ MailBuilder.php, line 90
Class
- MailBuilder
- Default mail builder.
Namespace
Drupal\simplenews\MailCode
public function buildSubscribeMail(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_subscribe_subscribed');
}
else {
$body = $this->config
->get('subscription.confirm_subscribe_unsubscribed');
}
$message['body'][] = $this->token
->replace($body, $context, [
'sanitize' => FALSE,
]);
}