You are here

function mailing_list_mail in Mailing List 8

Implements hook_mail().

File

./mailing_list.module, line 90
Contains the Mailing list module.

Code

function mailing_list_mail($key, &$message, $params) {

  /** @var \Drupal\mailing_list\SubscriptionInterface $subscription */
  $subscription = isset($params['subscription']) ? $params['subscription'] : NULL;
  switch ($key) {

    // Notify the subscriber about subscription limit reached.
    case 'subscription_limit_reached':
      $list_name = $subscription
        ->getList()
        ->label();
      $message['subject'] = t('Your subscription to the @list mailing list has failed', [
        '@list' => $list_name,
      ]);
      $message['body'][] = t('It was not possible to complete your subscription to the @list mailing list because you have reached the maximum number of subscriptions allowed.', [
        '@list' => $list_name,
      ]);
      $message['body'][] = t('You can modify or delete your existing subscriptions at the link below.');
      $message['body'][] = Url::fromRoute('entity.mailing_list_subscription.manage')
        ->setAbsolute()
        ->toString();
      break;
    case 'anonymous_subscription_access':
      $message['subject'] = t('Accessing your mailing list subscriptions');
      $message['body'][] = t('According to your request, you can modify or delete your existing subscriptions at the link below.');
      $message['body'][] = $params['manage_url'];
      break;
  }
}