Research Names
11-21-2002, 05:14 AM
I building a mailer for a paid E-mail script but it's not E-mailing or logging. It gives no error messages when called directly.
<?php
// This script is copyrighted to Pullan Enterprises
// You are not allowed to sell or give away this script
// You are not allowed to remove this header
require("program.php");
$db = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");
$mail_result = mysql_query("SELECT * FROM mailer WHERE progress<>'Pending' OR progress<>'Sent' ORDER BY sent",$db);
while ($mail = mysql_fetch_array($mail_result, MYSQL_ASSOC)) {
$mid = $mail["id"];
$start = $mail["progress"];
$end = $mail["last"];
$subject = $mail["subject"];
$body = $mail["body"];
$cs = $start;
if ($mail["rand"] == 'Yes') {
$limit = $start - $end;
$limit *= -1;
$result = mysql_query("SELECT * FROM members ORDER BY RAND() LIMIT $limit",$db);
} else {
$result = mysql_query("SELECT * FROM members ORDER BY joindate LIMIT $start,$end",$db);
}
while ($user = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $user["id"];
$pass = $user["pass"];
$email = $user["email"];
$first = $user["first"];
$last = $user["last"];
/* recipients */
$to = "$first $last <$email>";
$system_result = mysql_query("SELECT * FROM system WHERE id='Admin'",$db);
$system = mysql_fetch_array($system_result);
if ($mail["mask"] == 'Yes') {
$eheader = $system["mmheader"];
$efooter = $system["mmfooter"];
$body = "$eheader\n\n$body\n\n$efooter";
}
$subject = str_replace('~USERNAME~', $id, $subject);
$subject = str_replace('~PASSWORD~', $pass, $subject);
$subject = str_replace('~FIRSTNAME~', $first, $subject);
$subject = str_replace('~LASTNAME~', $last, $subject);
$body = str_replace('~USERNAME~', $id, $body);
$body = str_replace('~PASSWORD~', $pass, $body);
$body = str_replace('~FIRSTNAME~', $first, $body);
$body = str_replace('~LASTNAME~', $last, $body);
if ($mail["html"] == 'Yes') {
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
if ($mail["high"] == 'Yes') {
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
}
/* additional headers */
$headers .= "X-Mailer: PHP Mailer by Pullan Enterprises";
$headers .= "From: $pname <$admin_email>\r\n";
/* and now mail it */
mail($to, $subject, $body, $headers);
if ($cs != $end) { $progress = $cs; } else { $progress = 'Sent'; }
$update_status = "UPDATE system SET cid='$mid', cs='$cs' WHERE id='Admin'";
$update_result = mysql_query($update_status);
$update_status = "UPDATE mailer SET progress='$progress' WHERE id='$mid'";
$update_result = mysql_query($update_status);
$fp = fopen('log.txt', 'a');
fwrite($fp, "id $mid time $now email $email sent.\n");
fclose($fp);
usleep(10000000); // Wait 10 seconds
$cs++;
}
}
?>
<?php
// This script is copyrighted to Pullan Enterprises
// You are not allowed to sell or give away this script
// You are not allowed to remove this header
require("program.php");
$db = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect");
mysql_select_db("$dbname") or die("Could not select database");
$mail_result = mysql_query("SELECT * FROM mailer WHERE progress<>'Pending' OR progress<>'Sent' ORDER BY sent",$db);
while ($mail = mysql_fetch_array($mail_result, MYSQL_ASSOC)) {
$mid = $mail["id"];
$start = $mail["progress"];
$end = $mail["last"];
$subject = $mail["subject"];
$body = $mail["body"];
$cs = $start;
if ($mail["rand"] == 'Yes') {
$limit = $start - $end;
$limit *= -1;
$result = mysql_query("SELECT * FROM members ORDER BY RAND() LIMIT $limit",$db);
} else {
$result = mysql_query("SELECT * FROM members ORDER BY joindate LIMIT $start,$end",$db);
}
while ($user = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $user["id"];
$pass = $user["pass"];
$email = $user["email"];
$first = $user["first"];
$last = $user["last"];
/* recipients */
$to = "$first $last <$email>";
$system_result = mysql_query("SELECT * FROM system WHERE id='Admin'",$db);
$system = mysql_fetch_array($system_result);
if ($mail["mask"] == 'Yes') {
$eheader = $system["mmheader"];
$efooter = $system["mmfooter"];
$body = "$eheader\n\n$body\n\n$efooter";
}
$subject = str_replace('~USERNAME~', $id, $subject);
$subject = str_replace('~PASSWORD~', $pass, $subject);
$subject = str_replace('~FIRSTNAME~', $first, $subject);
$subject = str_replace('~LASTNAME~', $last, $subject);
$body = str_replace('~USERNAME~', $id, $body);
$body = str_replace('~PASSWORD~', $pass, $body);
$body = str_replace('~FIRSTNAME~', $first, $body);
$body = str_replace('~LASTNAME~', $last, $body);
if ($mail["html"] == 'Yes') {
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
if ($mail["high"] == 'Yes') {
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
}
/* additional headers */
$headers .= "X-Mailer: PHP Mailer by Pullan Enterprises";
$headers .= "From: $pname <$admin_email>\r\n";
/* and now mail it */
mail($to, $subject, $body, $headers);
if ($cs != $end) { $progress = $cs; } else { $progress = 'Sent'; }
$update_status = "UPDATE system SET cid='$mid', cs='$cs' WHERE id='Admin'";
$update_result = mysql_query($update_status);
$update_status = "UPDATE mailer SET progress='$progress' WHERE id='$mid'";
$update_result = mysql_query($update_status);
$fp = fopen('log.txt', 'a');
fwrite($fp, "id $mid time $now email $email sent.\n");
fclose($fp);
usleep(10000000); // Wait 10 seconds
$cs++;
}
}
?>
