473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help with email form

Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.

<?php
$to="gr**@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];

$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";

$head="From: fe**@fearofdolls.com";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>

Aug 7 '07 #1
20 1520
alice says...
Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.

<?php
$to="gr**@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];

$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";

$head="From: fe**@fearofdolls.com";
mail($to,$subject,"".$message,$head);
^^^^
dot not comma?
header("Location:thankyou.html");
?>

Aug 7 '07 #2
On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:
Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.

<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];

$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";

$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>
I can't see any reason why it wouldn't work, are you getting an error
message? if not, then the code is probably working and your problem is
that the SMTP server isn't properly set in your configurations.

Aug 7 '07 #3
On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
alice says...
Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);

^^^^
dot not comma?
header("Location:thankyou.html");
?>- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
So it should be mail($to,$subject,"",$message,$head);
?

Aug 7 '07 #4
On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
alice says...
Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);

^^^^
dot not comma?
header("Location:thankyou.html");
?>- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Well, doing that made something different happen...I got a message
from my ISPs proxy email relay, but not the content of the message I
mailed in the form.

Aug 7 '07 #5
On Aug 6, 11:15 pm, alice <al...@fearofdolls.comwrote:
On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
alice says...
Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
^^^^
dot not comma?
header("Location:thankyou.html");
?>- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -

So it should be mail($to,$subject,"",$message,$head);
?
No

The signature of PHP's mail function is:
bool mail ( string $to, string $subject, string $message [, string
$additional_headers [, string $additional_parameters]] )

meaning that if you use: mail($to,$subject,"",$message,$head) then
what will happen is PHP will consider $message to be your headers and
if it does work, it will just send a blank email because you are
passing "" as the message

I'd recommend you use mail($to,$subject,$message,$head); instead

Aug 7 '07 #6
On Aug 6, 7:15 pm, Loki25 <kgarnet...@gmail.comwrote:
On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:


Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>

I can't see any reason why it wouldn't work, are you getting an error
message? if not, then the code is probably working and your problem is
that the SMTP server isn't properly set in your configurations.- Hide quoted text -

- Show quoted text -
Not getting any error messages. Where are the configurations that you
speak of?

Aug 7 '07 #7
>
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -

- Show quoted text -
That still isn't working.

Aug 7 '07 #8
On Aug 6, 11:25 pm, alice <al...@fearofdolls.comwrote:
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -
- Show quoted text -

That still isn't working.
If you are running your own server, find your php.ini file and open it
up. look for do a search for the SMTP section (using your editor's
find command, it should be the first result)...you will see the
mail_function block configuration block...should look something like:

[mail function]
; For Win32 only.
SMTP = <your SMTP server address>

; For Win32 only.
sendmail_from = <your reply email address>

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =

enter this information if it is not already there, save the file and
restart your web server so the new settings take affect and try it
again.

Aug 7 '07 #9
On Aug 6, 7:30 pm, Loki25 <kgarnet...@gmail.comwrote:
On Aug 6, 11:25 pm, alice <al...@fearofdolls.comwrote:
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -
- Show quoted text -
That still isn't working.

If you are running your own server, find your php.ini file and open it
up. look for do a search for the SMTP section (using your editor's
find command, it should be the first result)...you will see the
mail_function block configuration block...should look something like:

[mail function]
; For Win32 only.
SMTP = <your SMTP server address>

; For Win32 only.
sendmail_from = <your reply email address>

; For Unix only. You may supply arguments as well (default: "sendmail
-t -i").
;sendmail_path =

enter this information if it is not already there, save the file and
restart your web server so the new settings take affect and try it
again.
I'm not running my own servier, but I guess I'll suggest this to my
ISP. I have had email forms work with this same site/ISP, I'm just
trying to change it slightly, borrowed the code from somewhere where
it seemed to work fine.

Aug 7 '07 #10
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.

Aug 7 '07 #11
On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.

Aug 8 '07 #12
In article <11**********************@e9g2000prf.googlegroups. com>, alice
says...
On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.

I finally got the mail to send, but now whatever I enter in the
message window does not get sent.

Are you using $message or $_POST['message']?

GM
Aug 8 '07 #13
alice wrote:
On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
>Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.

I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
What's your current code, and what is in the variables you are passing
the mail() function?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 8 '07 #14
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.

Are you using $message or $_POST['message']?

GM
I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";

So should this be
$message.="message: "$_POST['message']"\n";

or, I'm guessing here, if I don't want the word Message: to be in the
email body it would be
$message.=$_POST['message']"\n";

Aug 9 '07 #15
On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
Are you using $message or $_POST['message']?
GM

I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";

So should this be
$message.="message: "$_POST['message']"\n";

or, I'm guessing here, if I don't want the word Message: to be in the
email body it would be
$message.=$_POST['message']"\n";
if you were to do it that way, it would be: $message.=
$_POST['message']."\n"; (you were missing the [.])

Aug 10 '07 #16
On Aug 10, 9:25 am, Loki25 <kgarnet...@gmail.comwrote:
On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:


On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
Are you using $message or $_POST['message']?
GM
I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";
So should this be
$message.="message: "$_POST['message']"\n";
or, I'm guessing here, if I don't want the word Message: to be in the
email body it would be
$message.=$_POST['message']"\n";

if you were to do it that way, it would be: $message.=
$_POST['message']."\n"; (you were missing the [.])- Hide quoted text -

- Show quoted text -
Now I'm getting a blank page after clicking submit, and no mail is
showing up. Here is the mail.php code, with the address x'd out.
<?php
$to="x@xxxxxx";
$subject="web email";
$email=$_POST["email"];

$message="web email\n";
$message=.$_POST['message']."\n";
$head="From: x@xxxxx";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>

Aug 12 '07 #17
On Aug 12, 3:29 pm, alice <al...@fearofdolls.comwrote:
On Aug 10, 9:25 am, Loki25 <kgarnet...@gmail.comwrote:
On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Your html looks fine, your php looks fine and since you are using a
hosting service, we can assume your settings are fine. I also tested
the PHP script on my own server just to be sure nothing was over
looked. I replaced the $to address and it worked fine for me. Since
the exact code works fine on my server it leads me to believe that the
problem isn't in the code and it is instead on the server side. It
could be something as simple as their SMTP server being down for a
short while.
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
Are you using $message or $_POST['message']?
GM
I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";
So should this be
$message.="message: "$_POST['message']"\n";
or, I'm guessing here, if I don't want the word Message: to be in the
email body it would be
$message.=$_POST['message']"\n";
if you were to do it that way, it would be: $message.=
$_POST['message']."\n"; (you were missing the [.])- Hide quoted text -
- Show quoted text -

Now I'm getting a blank page after clicking submit, and no mail is
showing up. Here is the mail.php code, with the address x'd out.
<?php
$to="x@xxxxxx";
$subject="web email";
$email=$_POST["email"];

$message="web email\n";
$message=.$_POST['message']."\n";

$head="From: x@xxxxx";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>
Everything looks fine to me, I don't see anything wrong with your
code. But what I'm trying to figure out is the purpose of the empty
quotes just before the message in the mail function call. ("".$message)

Aug 13 '07 #18
Loki25 <kg********@gmail.comwrote in news:1186991766.268471.180630
@o61g2000hsh.googlegroups.com:
>$message="web email\n";
$message=.$_POST['message']."\n";
I think this should be

$message .= $_POST['message']."\n";
since the operator is .= not =.

Tim F
Aug 14 '07 #19
On Aug 14, 2:13 pm, Tim Ferguson <Ferguso...@softhome.netwrote:
Loki25 <kgarnet...@gmail.comwrote in news:1186991766.268471.180630
@o61g2000hsh.googlegroups.com:
$message="web email\n";
$message=.$_POST['message']."\n";

I think this should be

$message .= $_POST['message']."\n";

since the operator is .= not =.

Tim F
good catch

Aug 16 '07 #20
alice wrote:
On Aug 6, 7:15 pm, Loki25 <kgarnet...@gmail.comwrote:
>On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:


>>Can anyone tell me why this code won't work?
I've saved it as mail.php, and have a form on a web page with
action="mail.php" in the html. I've gotten this to work before on
other pages I've worked on, I can't figure out why it's not working
today, I must have forgotten something. The thank you page comes up,
but the mail is not actually delivered.
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>
I can't see any reason why it wouldn't work, are you getting an error
message? if not, then the code is probably working and your problem is
that the SMTP server isn't properly set in your configurations.- Hide quoted text -

- Show quoted text -

Not getting any error messages. Where are the configurations that you
speak of?
Just a note, but you should get a return value from mail() to say
whether it worked or not.

eg:
if ( !mail($to, $subject, $message, $head) ) {
exit("Achk... something not right.");
}

and also something to note, when I write out a header for a redirect
I always encapsulate it in an exit, i've used ti before in code and
found that header() doesn't actually quite your code, so you have
danger of some code after the header being executed... eg.

header( 'Location: offwego.php' );
// next line would execute even though the header redirects
mysql_query("DELETE FROM users WHERE user_id={$user_id}");

PS. Did you get this working? be careful from with From: field, some
server drop mail if the From is invalid.
Aug 16 '07 #21

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

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I donīt know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
17
by: Liam.M | last post by:
Hey guys, Forgive me if my question my be alittle silly, but I would very much appreciate and assistance that could be given! My situation is as follows: I have created a Button, and set...
23
by: casper christensen | last post by:
Hi I run a directory, where programs are listed based on the number of clicks they have recieved. The program with most clicks are placed on top and so on. Now I would like people to be apple to...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: karen987 | last post by:
This is an email form on an ASP page. I want to add validation before it submits, The current validation only checks "name, email, and content" (server side) if the spaces are empty. I need to add...
3
by: bdbeames | last post by:
Ok I have a form validation problem that I need one of you javascript ninja s to help me with. The following is a form with the javascript that I have used for the last year or two to validate. ...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.