You are here

function phpmailer_preview in PHPMailer 5.2

Same name and namespace in other branches
  1. 6.3 phpmailer.admin.inc \phpmailer_preview()
  2. 6 phpmailer.module \phpmailer_preview()
  3. 6.2 phpmailer.admin.inc \phpmailer_preview()
  4. 7.4 phpmailer.admin.inc \phpmailer_preview()
  5. 7.3 phpmailer.admin.inc \phpmailer_preview()

Menu callback; Render a HTML mail as preview in the browser.

1 string reference to 'phpmailer_preview'
phpmailer_menu in ./phpmailer.module
Implementation of hook_menu().

File

./phpmailer.module, line 205
Integrates the PHPMailer library for SMTP e-mail delivery.

Code

function phpmailer_preview() {
  global $user, $base_url;

  // Suppress devel output in preview.
  $GLOBALS['devel_shutdown'] = TRUE;
  $mailkey = 'phpmailer-test';

  // Use example address to prevent usage of configurable mail format setting.
  $recipient = 'test@example.com';

  // @see user_register_submit()
  $variables = array(
    '!username' => $user->name,
    '!site' => variable_get('site_name', 'Drupal'),
    '!password' => 'test',
    '!uri' => $base_url,
    '!uri_brief' => substr($base_url, strlen('http://')),
    '!mailto' => $user->mail,
    '!date' => format_date(time()),
    '!login_uri' => url('user', NULL, NULL, TRUE),
    '!edit_uri' => url('user/' . $user->uid . '/edit', NULL, NULL, TRUE),
    '!login_url' => user_pass_reset_url($user),
  );
  $subject = _user_mail_text('welcome_subject', $variables);
  $body = _user_mail_text('welcome_body', $variables);
  $sender = NULL;
  $headers = array();
  mimemail_mail_alter($mailkey, $recipient, $subject, $body, $sender, $headers);
  print theme('mimemail_message', $body, $mailkey);
  exit;
}