need help with code irregular working code
From: NotGiven (noname_at_nonegiven.net)
Date: 02/28/04
- Next message: Geoff Berrow: "Re: need help with code irregular working code"
- Previous message: JimC: "Prob in phpMyAdmin on IIS installation on Windows XP"
- Next in thread: Geoff Berrow: "Re: need help with code irregular working code"
- Reply: Geoff Berrow: "Re: need help with code irregular working code"
- Reply: Sandman: "Re: need help with code irregular working code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 Feb 2004 09:54:56 -0500
The code below is designed to loop through rows of a database query
obtaining email addresses and send an email to each. It is modified form
fomr some code I found on the net.
With each while loop, it updates the SENT field of the processed row to mark
it sent. I have a sleep function in there to slow the processing down to
see if that alleviated the following problem - it did help.
What is happening is the first 20 emails it sends correctly. Then it starts
sending with no $subject or $message but the remove form list text is still
in the email. When I did it for a client, some clients ending up geting 5
blank emails and one good email. It was bizarre and not uniformly wrong.
When I send it, I follow the progress in almost real time by monitoring the
test email account. When it started sending blank emails, I stop the web
form used for sending.
After I stopped it, I have about 35 emails. The database has about 1000
addresses. However, the database shows that ALL rows' sent field were
updated.
Any ideas of how to improve or rewrite this to work? Could it be that it is
on a shared server and there's something going on there?
Many thanks for your help!
<?
$subject = $_POST[subject];
$message = $_POST[message];
$sql2 = "select address from email_table";
$res2 = mysql_query($sql2) or die("Couldn't get addresses.");
$headers = "From: \"".FROMNAME."\" <".FROMEMAIL.">\r\n"; //from a config
file
$email['fromemail'] = "me@mydomain.com";
$headers .="Return-Path: <me@mydomain.com>\r\n";
while ($row = mysql_fetch_array($res2)) {
$email_addr = $row[0];
if (INSERTLINK == "true") {
$fullmessage = $message . "
-------------------------------------------------------
If you would like to remove yourself from this list and receive
no more emails, please click on the link below to do so.
" . BASEHREF . "unsubscribe.php?email=" . $email_addr . "
-------------------------------------------------------";
}
else {
$fullmessage = $message;
}
mail("$email_addr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}");
$sql3 = "UPDATE mail SET sent = 'y' WHERE address = '".$row[0]."'";
$res3 = mysql_query($sql3) or die("Couldn't update SENT field.");
sleep(4);
}
echo "email sent!";
?>
- Next message: Geoff Berrow: "Re: need help with code irregular working code"
- Previous message: JimC: "Prob in phpMyAdmin on IIS installation on Windows XP"
- Next in thread: Geoff Berrow: "Re: need help with code irregular working code"
- Reply: Geoff Berrow: "Re: need help with code irregular working code"
- Reply: Sandman: "Re: need help with code irregular working code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|