You are here

function newsletter_send_test in Newsletter 7

Sends a test newsletter to site administrator.

Parameters

$ntid: The newsletter template id.

$email: The email to send this newsletter to.NULL to use the site_mail instead.

1 call to newsletter_send_test()
newsletter_create_send_form_page_two_submit in includes/newsletter.admin.inc

File

includes/newsletter.admin.inc, line 1579
Admin page callbacks for the newsletter module.

Code

function newsletter_send_test($ntid, $mail = NULL) {
  if (!isset($mail)) {
    $mail = variable_get('site_mail');
  }
  $message = drupal_mail('newsletter', 'test-draft', $mail, language_default()->language, array(), $mail, FALSE);
  $message = array_merge($message, newsletter_create(array(), $ntid)
    ->preview());
  $message['format'] = variable_get('newsletter_format', 'html');
  $message['body'] = array(
    $message['body'],
  );
  $system = drupal_mail_system('newsletter', 'test-draft');
  $message = $system
    ->format($message);
  $status = $system
    ->mail($message);
  return $status ? drupal_set_message(t('Test mail sent succesfully')) : drupal_set_message(t('Test mail failed to send'));
}