mail() function sending two emails

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Here's my code:

$today = getdate();

$to =;

$subject = "New Application: ".$userdata["username"]." -  

$message_header = "New Application: ".$userdata["username"];

$message = $message_header."\n

Hello, is this working?";

mail($to, $subject, $message);

It's not located in a loop, so I don't understand why it would send 2 emails  
to the reciever?

Any idea's?

Re: mail() function sending two emails

Jesse Burns aka jburns131 wrote:
Quoted text here. Click to load it

If it's sending 2 emails, it's because:

a) You are calling the mail() function twice
b) Your To: header specifies two addresses, or
c) Your MTA is configured to copy someone automatically.

The most probably reason is you are calling mail() twice.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: mail() function sending two emails

Jerry Stuckle wrote:
Quoted text here. Click to load it

   Had the same problem once... it's a good chance that the script is  
being called twice. Usually caused by a page reload somewhere else in  
the HTML/Javascript. In my case I had a FORM that was getting posted  
twice but I can't remember what was causing the page to reload. I think  
it was some bad logic in conjunction with a header() call.


Re: mail() function sending two emails

Quoted text here. Click to load it

I had the *exact* same problem - weird as hell, ain't it?
It didn't happen on all pages, just the one - and even stepping through it  
in my code editor showed that I was not calling twice.
But still - two friggin mails.

I think it has something to do with the way the server administrator sets up  
the mail system.
In my case, sending to a bad email address didn't just return false - it  
crashed PHP.
I called the ISP and they immediately "fixed" it, so that bad sends returned  
But then - this problem cropped up.

The way I "solved" (for lack of a better word) was to, in that page, not put  
the mail() command in a function.
Instead, I put it inline with an if-then.

So... instead of this.
function fnDo() {

I used this:
function fnDo(){
    $bDo = true;

Site Timeline