Page 1 of 1

mail() creating duplicates

Posted: Tue Jun 13, 2006 3:00 pm
by t_catt11
Being no stranger to php or the good old mail() function, I feel... betrayed by it. Oh, it works well enough in a new application - too well, you might say. No matter what I seem to try, I get duplicates of each and every message.

I have tried removing the HTML tags (and appropriate headers), but still, the duplicates persist.

Code: Select all

$destination_email=$_POST['email'.$x]; 
$mail_subject="My Stress Tolerance is ".$_POST['stress']."%! What's Yours, ".$_POST['fname'.$x]."?"; 
$fromheader = "From: ".$_POST['username']." <stresstest@ratanjit.com>\r\n X-Mailer: PHP/" . phpversion()."\r\n";  
$fromheader.="MIME-Version 1.0 \r\n"; 
$fromheader.="Content-Type: text/html; charset=ISO-8859-1 \r\n"; 

$emailbody="<html><body>\r\n"; 
$emailbody.="I recently took a Stress Test from Stress-Free Expert Ratanjit online and my Stress Tolerance is ".$_POST['stress']."%.\n\r
"; 
$emailbody.="We all know that stress is all around us, ".$_POST['fname'.$x].", but do you know just how much it really affects you?\n\r
"; 
$emailbody.="Take Ratanjit's FREE Stress Test online to find out. All you have to do is visit <a href = \"http://www.stresstest.ratanjit.com\">stressstest.ratanjit.com</a> and answer 10 multiple choice questions. Ratanjit will even make personalized recommendations based on your results so you too can live Stress-Free! And best of all, it's totally FREE!\n\r
";  
$emailbody.="What's your score, ".$_POST['fname'.$x]."? Can you beat my Stress Tolerance? Go to <a href = \"http://www.stresstest.ratanjit.com\">stressstest.ratanjit.com</a> to find out!"; 
$emailbody.="</body></html>\r\n"; 
mail($destination_email, $mail_subject, $emailbody, $fromheader);
Since I essentially cut and pasted this code out of another workig site, I am stumpted as to why it doesn't work. Ideas?


Thanks,

Olan

Posted: Tue Jun 13, 2006 3:08 pm
by Christopher
I don't see anything obvious. Is this code being called twice by any chance?

unfortunately, no...

Posted: Tue Jun 13, 2006 3:19 pm
by t_catt11
...and it's driving me nuts! I've added debug code to print a confirmation to the screen after each time it is executed, but nope... only one "email sent" gets printed to the screen.

Posted: Tue Jun 13, 2006 3:36 pm
by Chris Corbyn
Have you tested if the same thing happens when you do a really simple single line mail() script without any logic?

interesting...

Posted: Tue Jun 13, 2006 3:52 pm
by t_catt11
If I don't put the headers in, it works. Testing some more.

or not...

Posted: Tue Jun 13, 2006 4:09 pm
by t_catt11
This one really has me stumped. Ideas welcome!

Re: or not...

Posted: Tue Jun 13, 2006 4:36 pm
by Chris Corbyn
t_catt11 wrote:This one really has me stumped. Ideas welcome!
Try something other than mail(). Hint hint....