You are here

function phpmailer_preview in PHPMailer 6.3

Same name and namespace in other branches
  1. 5.2 phpmailer.module \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 preview in the browser. @todo Move to Mime Mail project.

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

File

./phpmailer.admin.inc, line 240
Administrative functions for PHPMailer integration module.

Code

function phpmailer_preview() {
  global $user;

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

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

  // @see user_register_submit()
  $language = user_preferred_language($user);
  $variables = user_mail_tokens($user, $language);
  $variables['!password'] = 'test';
  $subject = _user_mail_text('register_no_approval_required_subject', $language, $variables);
  $body = _user_mail_text('register_no_approval_required_body', $language, $variables);
  $sender = NULL;
  $headers = array();

  // Convert non-html messages.
  // @see drupal_mail_wrapper()
  $format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
  $body = check_markup($body, $format, FALSE);

  // @see mimemail_prepare()
  $body = theme('mimemail_message', $body, $mailkey);
  foreach (module_implements('mail_post_process') as $module) {
    $function = $module . '_mail_post_process';
    $function($body, $mailkey);
  }
  print $body;
  exit;
}