473,241 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

need help with code irregular working code

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!";
?>
Jul 17 '05 #1
3 1769
I noticed that Message-ID: <aU*****************@bignews3.bellsouth.net>
from NotGiven contained the following:
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.");


You are updating the database, whether mail() is successful or not.
Since mail() returns TRUE if the mail was successfully accepted for
delivery, you might be better off trying
if(mail("$email_addr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}")){
//update database
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
That didn't work either - thanks though

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:7i********************************@4ax.com...
I noticed that Message-ID: <aU*****************@bignews3.bellsouth.net>
from NotGiven contained the following:
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.");


You are updating the database, whether mail() is successful or not.
Since mail() returns TRUE if the mail was successfully accepted for
delivery, you might be better off trying
if(mail("$email_addr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}")){
//update database
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #3
In article <aU*****************@bignews3.bellsouth.net>,
"NotGiven" <no****@nonegiven.net> wrote:
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.


Did you check your sendmail log (provided you use linux)? It might give you
some hints on what's happening.

--
Sandman[.net]
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kamil | last post by:
Hi , I’am having the following strange situation. First let me explain the configuration: Windows 2000 server with sql-server and running reportingservices. HP9000 Unix server with oracle...
3
by: slava.shklyar | last post by:
Hello, I'm writing some application that authenticates users via LDAP. When user going to login he sends user/pass by GET request to the application adn gets his ID back. Some users that have...
13
by: Rob Corwin | last post by:
Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
1
by: Cylix | last post by:
I have a form with a irregular background image, let say a circle. I would like the form shows and that fade out and close slowly. I have already done the fade out part by the timmer to set the...
5
by: sunil borwankar | last post by:
I am trying hard to make Custom Command Buttons of Irregular Shape and of Different colours in Active X Interface Wizard but am not successful. Irregular Shape Buttons i.e.; Triangular, Arrow Shape...
7
by: Manfred | last post by:
Hi, When I click any link on this page http://free.pages.at/staudinger/Regest/Regesten/_A1601-02-08-01657.xml it only "works" with IE 6 but not in IE 7. I need to know: 1. Does IE 7 throw an...
0
by: dr | last post by:
C# Irregular shaped user controls. How to make usercontrol have transparency key for its background image? I want to have irregular shaped user controls on my form. like a funny shaped button....
4
by: shihaoran | last post by:
Thx for the help for my other two programs. Here is a hard one; it is about makeing irregular polygon; i could not figure it out, help pls.... 1. Implement a class IrregularPolygon that...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.