You are here

function user_expire_mail in User Expire 8

Same name and namespace in other branches
  1. 7 user_expire.module \user_expire_mail()

Implements hook_mail().

File

./user_expire.module, line 446
Main module file for User expire module.

Code

function user_expire_mail($key, &$message, $params) {
  if ($key == 'expiration_warning') {
    $site_name = \Drupal::config('system.site')
      ->get('name');

    // The subject.
    $message['subject'] = t('@site_name: Account expiration warning', [
      '@site_name' => $site_name,
    ]);

    // The body.
    $message['body'][] = t('Hello @user', [
      '@user' => $params['account']
        ->getAccountName(),
    ]);

    // An empty string gives a newline.
    $message['body'][] = '';
    $message['body'][] = t('Because you have not logged in recently, your account at @site_name will be blocked in the near future. If you still use this site, please log in @login_url to avoid having your account blocked.', [
      '@site_name' => $site_name,
      '@login_url' => Url::fromRoute('entity.user.canonical', [
        'user' => \Drupal::currentUser()
          ->id(),
      ], [
        'absolute' => TRUE,
      ]),
    ]);
    $message['body'][] = '';
    $message['body'][] = t('Thanks, @site_name', [
      '@site_name' => $site_name,
    ]);
  }
}