/** * Send a set of test emails to a list of recipents. The recipients are created * in the composer page using the test addresses. */ function newsletter_send_test($recipients) { global $wpdb; newsletter_info(__FUNCTION__, 'Start'); $options = get_option('newsletter'); $options_email = get_option('newsletter_email'); @set_time_limit(100000); echo 'Sending to: <br />'; if (isset($options_email['novisual'])) { $message = $options_email['message']; } else { $message = '<html><head><style type="text/css">' . newsletter_get_theme_css($options_email['theme']) . '</style></head><body>' . $options_email['message'] . '</body></html>'; } if (newsletter_has_extras('1.0.4')) { newsletter_init_mail(); } foreach ($recipients as $r) { $url = newsletter_add_qs($options['url'], 'na=u&ni=' . $r->id . '&nt=' . $r->token); $m = newsletter_replace_url($message, 'UNSUBSCRIPTION_URL', $url); $m = newsletter_replace($m, $r); if (defined('NEWSLETTER_EXTRAS') && isset($options_email['track'])) { $m = newsletter_relink($m, $r->id, $options_email['name']); } $s = $options_email['subject']; $s = newsletter_replace($s, $r); $x = newsletter_mail($r->email, $s, $m, true); echo htmlspecialchars($r->name) . ' (' . $r->email . ') '; flush(); if ($x) { echo '[OK] -- '; newsletter_debug(__FUNCTION__, 'Sent to ' . $r->id . ' success'); } else { echo '[KO] -- '; newsletter_debug(__FUNCTION__, 'Sent to ' . $r->id . ' failed'); } } if (newsletter_has_extras('1.0.4')) { newsletter_close_mail(); } }
if (isset($_POST['save']) && check_admin_referer()) { $options = stripslashes_deep($_POST['options']); update_option('newsletter_email', $options); } // Auto composition if (isset($_POST['auto']) && check_admin_referer()) { // Load the theme $options = stripslashes_deep($_POST['options']); $file = newsletter_get_theme_dir($options['theme']) . '/theme.php'; // Execute the theme file and get the content generated ob_start(); @(include $file); $options['message'] = ob_get_contents(); ob_end_clean(); if ($options['novisual']) { $options['message'] = "<html>\n<head>\n<style type=\"text/css\">\n" . newsletter_get_theme_css($options_email['theme']) . "\n</style>\n</head>\n<body>\n" . $options['message'] . "\n</body>\n</html>"; } } // Reset the batch if (isset($_POST['reset']) && check_admin_referer()) { newsletter_delete_batch_file(); wp_clear_scheduled_hook('newsletter_cron_hook'); delete_option('newsletter_batch', array()); } if (isset($_POST['scheduled_simulate']) && check_admin_referer()) { $options = stripslashes_deep($_POST['options']); update_option('newsletter_email', $options); newsletter_send_scheduled(0, true); } if (isset($_POST['scheduled_send']) && check_admin_referer()) { $options = stripslashes_deep($_POST['options']);