954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP mail script sends multiple mails to recievers

Hi

I used the script from this old thread:
http://www.daniweb.com/web-development/php/threads/60795/page3
on a vps I have running drupal on a lamp stack.

I'm fetching the email address to send to from my database and then loops through all fetched addresses and sends the mail.

It works brilliantly, but my problem is that it works a little too well, meaning that it sends the mail multiple times - somewhere between 5 and 10 times.

Anyone have an idea as to why it does this ?

Cheers :)

andersiversen
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

turn the error suppression off for a start:

for example:

$ok = @mail($email_to, $email_subject, $email_message, $headers);


to

$ok = mail($email_to, $email_subject, $email_message, $headers);


then comment this line out perhaps and instead put:

echo "mail($email_to, $email_subject, $email_message, $headers)";


from this you should be able to get more information to help figuring out why its sending multiple emails. I suspect it will be your database query pulling the same email addresses multiple times.

kevindougans
Junior Poster
129 posts since Oct 2007
Reputation Points: 13
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: