You are here

function simplenews_send_test in Simplenews 5

Same name and namespace in other branches
  1. 6.2 includes/simplenews.mail.inc \simplenews_send_test()
  2. 6 simplenews.module \simplenews_send_test()
  3. 7.2 includes/simplenews.mail.inc \simplenews_send_test()
  4. 7 includes/simplenews.mail.inc \simplenews_send_test()

Send a test newsletter

1 call to simplenews_send_test()
simplenews_nodeapi in ./simplenews.module
Implementation of hook_nodeapi().

File

./simplenews.module, line 1294

Code

function simplenews_send_test($input) {
  $tid = db_result(db_query('SELECT tid FROM {simplenews_newsletters} WHERE nid = %d', $input->nid));
  $tid = $tid ? $tid : FALSE;
  $node = simplenews_node_prepare($input->nid, NULL, $tid);
  $term = $tid ? taxonomy_get_term($tid) : FALSE;
  $name = $term ? $term->name : 'Unassigned newsletter';
  $node->body .= "\n\n-- \n" . t('Footer will be appended here');
  $recipients = $input->test_address;
  foreach ($recipients as $to) {
    $node->to = $to;
    if (simplenews_mail_send($node)) {
      drupal_set_message(t('Test newsletter sent to %recipient.', array(
        '%recipient' => $to,
      )));
    }
  }
}