= '2.6.5') check_admin_referer('alo-easymail_main');
if(isset($_REQUEST['submit'])) {
// prepare array with recipients' addresses
$recipients = array();
// prepare for error
$error = "";
// Retrieve post info for TAG
$pID = $_REQUEST['select_post'];
if ((int)$pID) {
$obj_post = get_post($pID);
}
// If request add all SUBSCRIBERS
if ($_REQUEST['select_recipients'] == 'subscr') {
$subs = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}easymail_subscribers WHERE active='1'" );
foreach ($subs as $sub) {
$recipients[$sub->email]['email'] = $sub->email;
$recipients[$sub->email]['name'] = $sub->name;
$recipients[$sub->email]['firstname'] = $sub->name;
$recipients[$sub->email]['unikey'] = $sub->unikey;
}
// If request add all REGISTERED users
} else if ($_REQUEST['select_recipients'] == 'users') {
$reg_users = $wpdb->get_results( "SELECT ID AS UID, user_email FROM $wpdb->users" );
foreach ($reg_users as $reg_user) {
$recipients[$reg_user->user_email]['email'] = $reg_user->user_email;
$recipients[$reg_user->user_email]['name'] = ucfirst(get_usermeta($reg_user->UID, 'first_name'))." " .ucfirst(get_usermeta($reg_user->UID,'last_name'));
$recipients[$reg_user->user_email]['firstname'] = ucfirst(get_usermeta($reg_user->UID, 'first_name'));
}
}
// If any add NO-REGISTERED E-MAILS
if ($_REQUEST['emails_add']) {
$wrong_add_email = ""; // show them in error div
$non_reg_emails = explode(",", $_REQUEST['emails_add']);
foreach ($non_reg_emails as $non_reg_email) {
$trim_non_reg_email = trim($non_reg_email);
if (ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $trim_non_reg_email )) {
$recipients[$trim_non_reg_email]['email'] = $trim_non_reg_email;
} else {
$wrong_add_email .= $trim_non_reg_email." ";
}
}
}
// ------------------
// PREPARE THE E-MAIL
// ------------------
// From
$mail_sender = "noreply@". str_replace("www.","", $_SERVER['HTTP_HOST']);
// Headers
$headers = "MIME-Version: 1.0\n";
$headers .= "From: ".get_option('blogname')." <".$mail_sender.">\n";
//$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
// Subject
$subject = stripslashes($wpdb->escape($_REQUEST['input_subject']));
// Main content
$main_content = stripslashes($_REQUEST['content']);
$main_content = str_replace("\n", "
", $main_content);
// check input error: if any stop here
if ($subject == "" || $main_content == "") $error .= "- Fill 'subject' and 'main body' fields.
";
if ($_REQUEST['select_recipients'] == 'none' && trim($_REQUEST['emails_add']) == "") $error .= "- No recipients specified.
";
if ($error != "" || $wrong_add_email != "") {
//wp_redirect( get_option ('siteurl')."/".'wp-admin/edit.php?page=alo-easymail/alo-easymail_main.php&message='.$error);
echo " ";
echo "
$error
"; if ($wrong_add_email !="") echo "- Some inserted email addesses are incorrect, please check:
$wrong_add_email.
You have received this message because you subscribed our newsletter. If you want to unsubscribe please "; $updated_content .= "click here."; $updated_content .= "
"; } // ---- Send MAIL ---- $mail_engine = @wp_mail($recipient['email'], $subject, $updated_content, $headers); if($mail_engine) { $s ++; // add to success count $recipients[$recipient['email']]['result'] = 1; } else { $listnosent .= $recipient['email'].","; $e ++; // add to error count $recipients[$recipient['email']]['result'] = 0; } // some rest for the processor... if ( ($r % 50) == 0) { sleep(10); // every n° sent wait a little } // DEBUG //echo "";print_r ($rec);echo ""; }*/ // At the end: redirect //wp_redirect( get_option ('siteurl')."/".'wp-admin/edit.php?page=alo-easymail/alo-easymail_main.php&message=success&nsent='.$r.'&nsucc='.$s.'&listnosent='.$listnosent); echo " "; // reset Submit text //wp_enqueue_script( 'listman' ); //wp_print_scripts(); // REPORT echo "
| Name | Delivered | ".$n." | ".$recipient['email']." | ".$recipient['name']." | "; echo "
|---|
« back "; echo "
"; } exit; ?>