Hi all,My name is Julian, I am new to this forum and I send you all greetings from really down here....New Zealand I have an issue with my php mail function, I have asked my provider but they told me that they can`t help with coding.I have a page, success.php which does not output to screen. A successful credit card transaction is redirected here, the MySql database is queried 2 times to get details to insert in email and an email is sent out, at the moment to me, customer and website owner. Also the session is destroyed (will clear the shopping cart) and all ends with a redirection to the next page.The issue I have is that all 3 emails arrive in 2 copies each. This will be not so important if I will not send a copy out to customer. I noticed that all my other mail functions (which do not query the database, from other pages) are send out in one copy each.The code with comments is bellow if you can be bothered to have a look. Any suggestions are welcome.Thank you in advance,Julian

If you're getting two copies of each email, then either the page is loading a second time or your email system is CC'ing each other, which seems unlikely. Have you checked your server mail log to confirm that PHP is actually sending two copies of the email?

Your while loop ends before the mail is sent, so I don't see how multiple copies would be sent from this snippet of code alone.

Sogo7
—
2012-08-20T02:09:04Z —
#3

julianStefan said:

all 3 emails arrive in 2 copies each

Just to be sure add " LIMIT 1" to the end of the $sql variable for obtaining customer details, cant quite figure out why there is a while loop in there at all...

and take a closer look at the page calling the mail script for a misconfigured event trigger.

julianStefan
—
2012-08-20T05:03:25Z —
#4

Sure will add Limit 1 thanks ....About the loop....What are you using to get just one result out of a MySql table?

martbean
—
2012-08-20T08:47:26Z —
#5

I usually find it's helpful to echo the mail command to see exactly what's happening:

echo "mail($to, $subject, $message, $headers)";

If you do that for every mail() you'll be able to see if it's sending twice or the problem is elsewhere. Also might be worth checking the full headers once you receive the email, to see if there are any clues there.

As for getting the result of one row only, just omit the while():

$row = mysql_fetch_array($result);

julianStefan
—
2012-08-21T00:48:56Z —
#6

Hi Guys,Thank you all for your help. Looks like the "double" is caused by the page calling the success.php page That one is modified by me from a sample given by the credit card company. Is functional but looks a bit messy at the moment. if anyone has time and mood to have a look at it let me know.Anyway thank you all for your time, I really appreciate it.