473,586 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($sq l2) or die("Couldn't get addresses.");
$headers = "From: \"".FROMNAME."\ " <".FROMEMAIL."> \r\n"; //from a config
file
$email['fromemail'] = "me@mydomain.co m";
$headers .="Return-Path: <me@mydomain.co m>\r\n";
while ($row = mysql_fetch_arr ay($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.ph p?email=" . $email_addr . "
-------------------------------------------------------";
}
else {
$fullmessage = $message;
}
mail("$email_ad dr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}");
$sql3 = "UPDATE mail SET sent = 'y' WHERE address = '".$row[0]."'";
$res3 = mysql_query($sq l3) or die("Couldn't update SENT field.");
sleep(4);
}
echo "email sent!";
?>
Jul 17 '05 #1
3 1787
I noticed that Message-ID: <aU************ *****@bignews3. bellsouth.net>
from NotGiven contained the following:
mail("$email_ad dr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}");
$sql3 = "UPDATE mail SET sent = 'y' WHERE address = '".$row[0]."'";
$res3 = mysql_query($sq l3) 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.c om...
I noticed that Message-ID: <aU************ *****@bignews3. bellsouth.net>
from NotGiven contained the following:
mail("$email_ad dr", "$subject", $fullmessage, $headers, "-f
{$email[fromemail]}");
$sql3 = "UPDATE mail SET sent = 'y' WHERE address = '".$row[0]."'";
$res3 = mysql_query($sq l3) 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****@nonegiv en.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
3082
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 9i database I’ve installed oracle client client tools on the W2K server and
3
1486
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 irregular characters in the password ( !^&%@#... ) can not login. I tried to encode password ($_SERVER) with urlencode() and base64_encode() but it...
13
5687
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 linearly during execution and eventually crashes the computer. without going into too much detail of my code, i made the following observations:...
18
2254
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 then want to use the string on the same page. My script is: function checkRadio(field) { for(var i=0; i < field.length; i++) {
1
1611
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 form opacity. However, I set the transparent key of the form be white in color, when the form start to fade out, The white part of the form is not...
5
11530
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 and Hexagonal are made and are responding in click event but I am not able to provide colors to them. I used Window API programming also but buttons...
7
1428
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 error msg? 2. Line number ? I would greatly appreciate any help.
0
1670
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. This works fine for irregular shaped forms becuase they have a transparency key field, but user controls dont have this field. note i do not want to...
4
4444
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 contains an array list of Point2D.Double objects. 2. The Point2D.Double class defines a point specified in double precision representing a location in...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.