mail() function sending two emails

mail() function sending two emails

am 24.11.2007 20:55:45 von Jesse Burns aka jburns131

Here's my code:

$today = getdate();

$to = someone@somewhere.com;

$subject = "New Application: ".$userdata["username"]." -
".$today['mon']."/".$today['mday']."/".$today['year'];

$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

am 24.11.2007 21:04:05 von Jerry Stuckle

Jesse Burns aka jburns131 wrote:
> Here's my code:
>
> $today = getdate();
>
> $to = someone@somewhere.com;
>
> $subject = "New Application: ".$userdata["username"]." -
> ".$today['mon']."/".$today['mday']."/".$today['year'];
>
> $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?
>
>
>

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.
jstucklex@attglobal.net
==================

Re: mail() function sending two emails

am 24.11.2007 21:18:06 von Bucky Kaufman

"Jesse Burns aka jburns131" wrote in message
news:J42dncuPMqdeHNXanZ2dnUVZ_hCdnZ2d@comcast.com...

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

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
false.
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() {
mail();
}

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

Re: mail() function sending two emails

am 24.11.2007 21:46:47 von Jesse Burns aka jburns131

Thanks for the input :-)

ok, here's where it gets really odd. Out of the 2 email sent, only one has
the $_POST data that I'm sending. The other doesn't?

Any idea's?


"Jesse Burns aka jburns131" wrote in message
news:J42dncuPMqdeHNXanZ2dnUVZ_hCdnZ2d@comcast.com...
> Here's my code:
>
> $today = getdate();
>
> $to = someone@somewhere.com;
>
> $subject = "New Application: ".$userdata["username"]." -
> ".$today['mon']."/".$today['mday']."/".$today['year'];
>
> $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

am 24.11.2007 21:53:52 von Jerry Stuckle

Jesse Burns aka jburns131 wrote:
> Thanks for the input :-)
>
> ok, here's where it gets really odd. Out of the 2 email sent, only one has
> the $_POST data that I'm sending. The other doesn't?
>
> Any idea's?
>
>
> "Jesse Burns aka jburns131" wrote in message
> news:J42dncuPMqdeHNXanZ2dnUVZ_hCdnZ2d@comcast.com...
>> Here's my code:
>>
>> $today = getdate();
>>
>> $to = someone@somewhere.com;
>>
>> $subject = "New Application: ".$userdata["username"]." -
>> ".$today['mon']."/".$today['mday']."/".$today['year'];
>>
>> $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?
>>
>>
>
>
>

Yep, you're probably calling mail() somewhere else. Or calling it twice
- i.e. after reloading the page.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: mail() function sending two emails

am 25.11.2007 06:35:05 von FFMG

Jesse Burns aka jburns131;105125 Wrote:
> Thanks for the input :-)
>
> ok, here's where it gets really odd. Out of the 2 email sent, only one
> has
> the $_POST data that I'm sending. The other doesn't?
>
> Any idea's?
>
>

It really looks like the page is reloaded.
Do you have some kind of redirect in your code?, something to reload
the page?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------ ------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=22557

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

Re: mail() function sending two emails

am 25.11.2007 17:19:36 von Michael Fesser

..oO(Jesse Burns aka jburns131)

>Thanks for the input :-)
>
>ok, here's where it gets really odd. Out of the 2 email sent, only one has
>the $_POST data that I'm sending. The other doesn't?
>
>Any idea's?

What does the server logfile say? Is the page requested twice?

Micha

Re: mail() function sending two emails

am 25.11.2007 17:56:39 von Jesse Burns aka jburns131

Hello :-)

I'm not very familiar with what and where the server logfile is. I have full
control of my server, and cpanel/whm. Could you please point me to where the
logfile might be?

Thanks in advance.

"Michael Fesser" wrote in message
news:s18jk3d2pe0a5f0bkrb8kmec7mrtlim3f5@4ax.com...
> .oO(Jesse Burns aka jburns131)
>
>>Thanks for the input :-)
>>
>>ok, here's where it gets really odd. Out of the 2 email sent, only one has
>>the $_POST data that I'm sending. The other doesn't?
>>
>>Any idea's?
>
> What does the server logfile say? Is the page requested twice?
>
> Micha

Re: mail() function sending two emails

am 26.11.2007 00:57:07 von Michael Fesser

..oO(Jesse Burns aka jburns131)

>I'm not very familiar with what and where the server logfile is. I have full
>control of my server, and cpanel/whm. Could you please point me to where the
>logfile might be?

Usually on *nix systems it's somewhere in /var/log, but dependent on the
system and server setup the location might differ. I'm not familiar with
cPanel (usually I either use a direct SSH login or my host's own admin
software) - does it have an option to access the server logs? Sometimes
you might also be able to reach them via FTP. If you still can't get
them, ask your host.

Micha

Re: mail() function sending two emails

am 26.11.2007 03:44:54 von darko

On Nov 25, 5:56 pm, "Jesse Burns aka jburns131"
wrote:
> Hello :-)
>
> I'm not very familiar with what and where the server logfile is. I have full
> control of my server, and cpanel/whm. Could you please point me to where the
> logfile might be?
>
> Thanks in advance.
>
> "Michael Fesser" wrote in message
>
> news:s18jk3d2pe0a5f0bkrb8kmec7mrtlim3f5@4ax.com...
>
> > .oO(Jesse Burns aka jburns131)
>
> >>Thanks for the input :-)
>
> >>ok, here's where it gets really odd. Out of the 2 email sent, only one has
> >>the $_POST data that I'm sending. The other doesn't?
>
> >>Any idea's?
>
> > What does the server logfile say? Is the page requested twice?
>
> > Micha

Smells to me you're require-ing this file from somewhere and your code
gets
required twice. Try doing the require_once, or organize your code
better.

Just an idea, though.

Darko

Re: mail() function sending two emails

am 26.11.2007 12:26:22 von Norman Peelman

Jerry Stuckle wrote:
> Jesse Burns aka jburns131 wrote:
>> Here's my code:
>>
>> $today = getdate();
>>
>> $to = someone@somewhere.com;
>>
>> $subject = "New Application: ".$userdata["username"]." -
>> ".$today['mon']."/".$today['mday']."/".$today['year'];
>>
>> $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?
>>
>>
>>
>
> 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.
>

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.

Norm