maestrodamuz Posted January 11, 2009 Share Posted January 11, 2009 I am working on an emailing application and I am using the mail() function. But any time I send email 2 copies are sent instead. This is my mailing script //create a From: mailheader $headers = "From:".$_POST['geduemail']; //loop through results and send mail while ($row = mysql_fetch_array($emails)) { set_time_limit(0); $email = $_POST['email']; mail("$email", stripslashes($_POST['subject']), stripslashes($_POST['message']), $headers); } I will appreciate any help in debugging this. Link to comment https://forums.phpfreaks.com/topic/140345-mail-function-problem/ Share on other sites More sharing options...
ratcateme Posted January 11, 2009 Share Posted January 11, 2009 why are you in the loop? you don't get any vars from $row so i am guessing that the mysql query returns two rows so it sends the email twice try just $headers = "From:".$_POST['geduemail']; set_time_limit(0); $email = $_POST['email']; mail("$email", stripslashes($_POST['subject']), stripslashes($_POST['message']), $headers); or should it look something like this $headers = "From:".$_POST['geduemail']; //loop through results and send mail while ($row = mysql_fetch_array($emails)) { set_time_limit(0); $email = $row['email']; //get email from database? mail("$email", stripslashes($_POST['subject']), stripslashes($_POST['message']), $headers); } Scott. Link to comment https://forums.phpfreaks.com/topic/140345-mail-function-problem/#findComment-734379 Share on other sites More sharing options...
maestrodamuz Posted January 11, 2009 Author Share Posted January 11, 2009 Thanks Scott, I used the $_POST because I am submitting the email value from a form. I have dealt with the problem, as U rightly asked "why am I in the loop?". The script was actually modified from a mass emailer script, so i have removed the loop and the script is now working fine. Thank you. Link to comment https://forums.phpfreaks.com/topic/140345-mail-function-problem/#findComment-734381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.