You are here

function swiftmailer_mail in Swift Mailer 8

Same name and namespace in other branches
  1. 8.2 swiftmailer.module \swiftmailer_mail()
  2. 7 swiftmailer.module \swiftmailer_mail()

Implements hook_mail().

File

./swiftmailer.module, line 46
This is the primary module file.

Code

function swiftmailer_mail($key, &$message) {
  $user = \Drupal::currentUser();
  $message['headers']['Content-Type'] = SWIFTMAILER_FORMAT_HTML;
  $text[] = '<h3>' . t('Dear @user,', [
    '@user' => $user
      ->getDisplayName(),
  ]) . '</h3>';
  $text[] = '<p>' . t('This e-mail has been sent from @site by the Swift Mailer module. The module has been successfully configured.', [
    '@site' => \Drupal::config('system.site')
      ->get('name'),
  ]) . '</p>';
  $text[] = t('Kind regards') . '<br /><br />';
  $text[] = t('The Swift Mailer module');
  $message['subject'] = t('Swift Mailer has been successfully configured!');
  $message['body'] = array_map(function ($text) {
    return Markup::create($text);
  }, $text);
}