473,511 Members | 15,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mail() function sending two emails

Here's my code:

$today = getdate();

$to = so*****@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?
Nov 24 '07 #1
10 16485
Jesse Burns aka jburns131 wrote:
Here's my code:

$today = getdate();

$to = so*****@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.
js*******@attglobal.net
==================

Nov 24 '07 #2
"Jesse Burns aka jburns131" <jb*******@jbwebware.comwrote in message
news:J4******************************@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();
}


Nov 24 '07 #3
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" <jb*******@jbwebware.comwrote in message
news:J4******************************@comcast.com. ..
Here's my code:

$today = getdate();

$to = so*****@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?


Nov 24 '07 #4
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" <jb*******@jbwebware.comwrote in message
news:J4******************************@comcast.com. ..
>Here's my code:

$today = getdate();

$to = so*****@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.
js*******@attglobal.net
==================

Nov 24 '07 #5

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

Nov 25 '07 #6
..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
Nov 25 '07 #7
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" <ne*****@gmx.dewrote in message
news:s1********************************@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

Nov 25 '07 #8
..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
Nov 26 '07 #9
On Nov 25, 5:56 pm, "Jesse Burns aka jburns131"
<jburns...@jbwebware.comwrote:
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" <neti...@gmx.dewrote in message

news:s1********************************@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
Nov 26 '07 #10
Jerry Stuckle wrote:
Jesse Burns aka jburns131 wrote:
>Here's my code:

$today = getdate();

$to = so*****@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
Nov 26 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2212
by: VB Programmer | last post by:
My company has it's own webserver, which is going to host our ASP.NET web application. We want the website to be able to send out emails. 1. What do I need on the server so that it has the...
2
9207
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
2
1672
by: martintillbrook | last post by:
I am using the simple mail() fucntion in a php script but the emails that are being generated and being trapped by Microsoft Exchange server 2003 Inteligent message filter as having an SCL rating...
1
4775
by: crescent_au | last post by:
I am developing a simple mailing system. This requires sending emails in HTML format to one or more recipient. I am currently using PHP's mail() function. It works alright but it doesn't seem...
1
2939
by: akuva | last post by:
I have to send more than 100s of email using a php code if i use mail function whether it will be sent to spam or inbox. If it is sent to spam which is the other way to send mass email from php. i...
8
9280
LacrosseB0ss
by: LacrosseB0ss | last post by:
Hey all! I am coding a page in php to send an e-mail to 2 addresses (to and cc). The user fills out 2 text boxes on a form. The first will be the body of the message and the 2nd is return...
0
1140
by: b00gieman | last post by:
Hi! I have problems with an email component developed using cdo message.I don't get any kind of error,but the messages don't reach rhe destination.The application is developed in visual basic.Here's...
3
2187
by: shybe | last post by:
I have a send mail script on my site that. The emails are recieved by gmail, and yahoo, but not to mail clients like Outlook, Mail, etc...) Is this a problem with the script, or is it...
12
5054
by: noha khalifa | last post by:
Hi all, I want to send mails using php mail() function, my web server is apache on linux i just add this line to my code ini_set('sendmail_from', 'users@must.edu.eg'); i'm sending emails to...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.