I used the script from this old thread:
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);


$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.