Forum Moderators: coopster

Message Too Old, No Replies

mail function sending double emails

double email problems

         

johnquest

4:18 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



I have a script I'm using to send me e-mails when someone registers for an event I'm holding. But it's sending the e-mails twice. How can I fix this? Can anyone help? My host uses qmail. I get no errors reported. Here is the function as I'm using it:

mail('address1@host, address2@host', $subject, $messageproper, "From: \"$yourname\" <$email>\nX-Sender: My site name" );

I have a value passed to the variables "yourname", "subject", "messageproper", "email" from a form I've set up.

Any ideas what's causing the double emails and how to solve this problem?

Thanks,

Johnquest

dreamcatcher

4:48 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi johnquest,

I don`t think you can have two e-mail addresses in the mail() function. For your example, try using two seperate functions. ie:

mail('address1@host', $subject, $messageproper, "From: \"$yourname\" <$email>\nX-Sender: My site name" );
mail('address2@host', $subject, $messageproper, "From: \"$yourname\" <$email>\nX-Sender: My site name" );

:)

jatar_k

5:38 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can have even more than 2 emails in the $to portion of the mail function with out problems. It is the same as specifying multiple to addresses in your favourite mail program.

Have you made sure the 2 emails are right? You are actually sending 2 emails by using them in the function. Sending the emails twice to who? Who is supposed to be sending the first and second email to?

johnquest

5:51 pm on Dec 3, 2003 (gmt 0)

10+ Year Member



I would like to send "one" email to two addresses; instead the script is sending the e-mail twice to both addresses, four times total. Both inboxes get duplicate e-mails.

I tried the above idea of having one address per mail function and this works fine, but I agree, the $to portion of the mail function should be able to take many addresses and send one e-mail to each. Why are there duplicates being sent?

Thanks,

johnquest

jatar_k

5:55 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try having one in the to: portion and cc the other.

coopster

6:35 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Make sure the mail() function isn't inside of a loop that is iterating more than once. You could place an exit() statement after the mail() function to start narrowing it down.

dreamcatcher

9:25 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can have even more than 2 emails in the $to portion of the mail function with out problems.

Wow, I never new that! :)