<?php
//////////////////////////////////////////////////////////////////////////////
// //
// Jason's Mass Mailer v1.2 //
// //
// [[url]http://www.rottmansales.com/jason/[/url]] //
//////////////////////////////////////////////////////////////////////////////
// Configure the following variables //
//////////////////////////////////////////////////////////////////////////////
$host = "localhost"; //Host
$user = ""; //Username
$pass = ""; //Password
$database = ""; //Database name
$table = ""; //Name of table that has list of emails
$column = ""; //Name of column in table that has list of emails
$num_per_loop = "5"; //Number of emails sent per page loop (keep number low to avoid page time-out)
$from_name = "Jason Rottman (Developer)"; //Reply address email address
$from_email = ""; //Name the emails came from
$mail_subject = "This is the subject of the message";
$mail_body = "This is the body of the message (you can use html)";
$send_html_messages = "yes"; //yes - Send html messages, no - Do not send html messages
//////////////////////////////////////////////////////////////////////////////
// DO NOT CHANGE ANYTHING BELOW THIS LINE //
//////////////////////////////////////////////////////////////////////////////
if (($first_time == "yes") || ($first_time == "")) {
$total_sent = "0";
$total_time = "0";
$start = "0";
$num_to_end = $num_per_loop;
}
if ($first_time == "no") {
$start = $start;
$num_to_end = $num_per_loop;
}
$mydb = mysql_connect($host,$user,$pass);
if (!$mydb) { echo "Error connecting to database"; die; }
mysql_select_db($database);
$varx = $start + $num_to_end + 1;
$result2 = mysql_query("SELECT " . $column . " FROM " . $table . " LIMIT " . $start . ", " . $varx . "") or die(mysql_error());
$num_left = "0";
$clock_start = number_format(microtime(),3);
while(list($email_addr) = mysql_fetch_row($result2)) {
$num_left = $num_left + 1;
}
$result3 = mysql_query("SELECT " . $column . " FROM " . $table . " LIMIT " . $start . ", " . $num_to_end . "") or die(mysql_error());
while (list($column) = mysql_fetch_row($result3)) {
$xheaders = "From: " . $from_name . " <" . $from_email . ">\n";
$xheaders .= "X-Sender: <" . $from_email . ">\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 6\n"; // Urgent message!
if ($send_html_messages == "yes") {
$xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
}
mail("$column",
"$mail_subject",
"$mail_body",
$xheaders);
$total_sent = $total_sent + 1;
}
$clock_stop = number_format(microtime(),3);
$clock_difference = $clock_stop - $clock_start;
$total_time = $total_time + $clock_difference;
mysql_close();
if ($num_left > $num_per_loop) {
$next_start = $start + $num_per_loop;
//echo "<a href=\"" . $PHP_SELF . "?first_time=no&start=" . $next_start . "&total_sent=" . $total_sent . "&total_time=" . $total_time . "\">Next " . $num_per_loop . "</a>\n";
header("Location: " . $PHP_SELF . "?first_time=no&start=" . $next_start . "&total_sent=" . $total_sent . "&total_time=" . $total_time . "");
}
if ($num_left <= $num_per_loop) {
echo "FINISHED<br><br>";
echo "Total Emails Sent: " . $total_sent . "<br>\n";
echo "Total Script Run Time Used: " . $total_time . " seconds<br>\n";
echo "<a href=\"" . $PHP_SELF . "\">Run Again</a><br><br><br>\n";
echo "Provided By: <a href=\"http://www.rottmansales.com/jason/\">[url]http://www.rottmansales.com/jason/[/url]</a><br>\n";
end;
}
?>
Hi, this script is a mass mailer script (obviously). Anyways... What it does is it pulls all the email address'es out of $collumn and and emails them all. Well i have another collumn in my database called "active". I only want the script to email people in $collumn WHERE active = yes. Well im not very good at query's so if someone could edit the code above to do that, it would be VERRY helpfull!! I've been trying for a little bit and just keep on getting error this and error that..... THANKS SO MUCH FOR YOUR TIME! 🙂
🙂 🙂 🙂