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 :)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.