Connecting Tech Pros Worldwide Help | Site Map

help with email form

alice
Guest
 
Posts: n/a
#1: Aug 7 '07
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="greg@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: fear@fearofdolls.com";
mail($to,$subject,"".$message,$head);
header("Location:thankyou.html");
?>

Geoff Muldoon
Guest
 
Posts: n/a
#2: Aug 7 '07

re: help with email form


alice says...
Quote:
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="greg@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: fear@fearofdolls.com";
mail($to,$subject,"".$message,$head);
^^^^
dot not comma?
Quote:
header("Location:thankyou.html");
?>
>
>
Loki25
Guest
 
Posts: n/a
#3: Aug 7 '07

re: help with email form


On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:
Quote:
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.

alice
Guest
 
Posts: n/a
#4: Aug 7 '07

re: help with email form


On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
Quote:
alice says...
>
>
>
Quote:
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.
>
Quote:
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
>
Quote:
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
>
Quote:
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
>
^^^^
dot not comma?
>
>
>
Quote:
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);
?

alice
Guest
 
Posts: n/a
#5: Aug 7 '07

re: help with email form


On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
Quote:
alice says...
>
>
>
Quote:
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.
>
Quote:
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
>
Quote:
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
>
Quote:
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
>
^^^^
dot not comma?
>
>
>
Quote:
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.

Loki25
Guest
 
Posts: n/a
#6: Aug 7 '07

re: help with email form


On Aug 6, 11:15 pm, alice <al...@fearofdolls.comwrote:
Quote:
On Aug 6, 7:03 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
>
>
>
Quote:
alice says...
>
Quote:
Quote:
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.
>
Quote:
Quote:
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
>
Quote:
Quote:
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
>
Quote:
Quote:
$head="From: f...@fearofdolls.com";
mail($to,$subject,"".$message,$head);
>
Quote:
^^^^
dot not comma?
>
Quote:
Quote:
header("Location:thankyou.html");
?>- Hide quoted text -
>
Quote:
- Show quoted text -- Hide quoted text -
>
Quote:
- 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

alice
Guest
 
Posts: n/a
#7: Aug 7 '07

re: help with email form


On Aug 6, 7:15 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:
>
>
>
>
>
Quote:
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.
>
Quote:
<?php
$to="g...@fearofdolls.com";
$subject="Fear of Dolls web email";
$email=$_POST["email"];
>
Quote:
$message="From Fear of Dolls web email\n";
$message.="message: ".$message."\n";
>
Quote:
$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?

alice
Guest
 
Posts: n/a
#8: Aug 7 '07

re: help with email form


Quote:
>
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -
>
- Show quoted text -
That still isn't working.

Loki25
Guest
 
Posts: n/a
#9: Aug 7 '07

re: help with email form


On Aug 6, 11:25 pm, alice <al...@fearofdolls.comwrote:
Quote:
Quote:
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -
>
Quote:
- 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.

alice
Guest
 
Posts: n/a
#10: Aug 7 '07

re: help with email form


On Aug 6, 7:30 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
On Aug 6, 11:25 pm, alice <al...@fearofdolls.comwrote:
>
Quote:
Quote:
I'd recommend you use mail($to,$subject,$message,$head); instead- Hide quoted text -
>
Quote:
Quote:
- Show quoted text -
>
Quote:
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.

Loki25
Guest
 
Posts: n/a
#11: Aug 7 '07

re: help with email form


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.

alice
Guest
 
Posts: n/a
#12: Aug 8 '07

re: help with email form


On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
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.

Geoff Muldoon
Guest
 
Posts: n/a
#13: Aug 8 '07

re: help with email form


In article <1186532720.113030.138210@e9g2000prf.googlegroups. com>, alice
says...
Quote:
On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
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
Jerry Stuckle
Guest
 
Posts: n/a
#14: Aug 8 '07

re: help with email form


alice wrote:
Quote:
On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
>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.
jstucklex@attglobal.net
==================
alice
Guest
 
Posts: n/a
#15: Aug 9 '07

re: help with email form


On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
Quote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
Quote:
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.
>
Quote:
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";

Loki25
Guest
 
Posts: n/a
#16: Aug 10 '07

re: help with email form


On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:
Quote:
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
>
>
>
Quote:
In article <1186532720.113030.138...@e9g2000prf.googlegroups. com>, alice
says...On Aug 6, 11:43 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
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.
>
Quote:
Quote:
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
>
Quote:
Are you using $message or $_POST['message']?
>
Quote:
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 [.])

alice
Guest
 
Posts: n/a
#17: Aug 12 '07

re: help with email form


On Aug 10, 9:25 am, Loki25 <kgarnet...@gmail.comwrote:
Quote:
On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:
>
>
>
>
>
Quote:
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
>
Quote:
Quote:
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.
>
Quote:
Quote:
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
>
Quote:
Quote:
Are you using $message or $_POST['message']?
>
Quote:
Quote:
GM
>
Quote:
I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";
>
Quote:
So should this be
$message.="message: "$_POST['message']"\n";
>
Quote:
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");
?>

Loki25
Guest
 
Posts: n/a
#18: Aug 13 '07

re: help with email form


On Aug 12, 3:29 pm, alice <al...@fearofdolls.comwrote:
Quote:
On Aug 10, 9:25 am, Loki25 <kgarnet...@gmail.comwrote:
>
>
>
Quote:
On Aug 9, 1:07 pm, alice <al...@fearofdolls.comwrote:
>
Quote:
Quote:
On Aug 7, 6:16 pm, Geoff Muldoon <geoff.muld...@trap.gmail.comwrote:
>
Quote:
Quote:
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.
>
Quote:
Quote:
I finally got the mail to send, but now whatever I enter in the
message window does not get sent.
>
Quote:
Quote:
Are you using $message or $_POST['message']?
>
Quote:
Quote:
GM
>
Quote:
Quote:
I'm not in front of it now, but I can see from my earlier post that
I'm using
$message.="message: ".$message."\n";
>
Quote:
Quote:
So should this be
$message.="message: "$_POST['message']"\n";
>
Quote:
Quote:
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";
>
Quote:
if you were to do it that way, it would be: $message.=
$_POST['message']."\n"; (you were missing the [.])- Hide quoted text -
>
Quote:
- 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)

Tim Ferguson
Guest
 
Posts: n/a
#19: Aug 14 '07

re: help with email form


Loki25 <kgarnett24@gmail.comwrote in news:1186991766.268471.180630
@o61g2000hsh.googlegroups.com:
Quote:
Quote:
>$message="web email\n";
>$message=.$_POST['message']."\n";
>>
>
I think this should be

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


since the operator is .= not =.

Tim F
Loki25
Guest
 
Posts: n/a
#20: Aug 16 '07

re: help with email form


On Aug 14, 2:13 pm, Tim Ferguson <Ferguso...@softhome.netwrote:
Quote:
Loki25 <kgarnet...@gmail.comwrote in news:1186991766.268471.180630
@o61g2000hsh.googlegroups.com:
>
Quote:
Quote:
$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

Tyno Gendo
Guest
 
Posts: n/a
#21: Aug 16 '07

re: help with email form


alice wrote:
Quote:
On Aug 6, 7:15 pm, Loki25 <kgarnet...@gmail.comwrote:
Quote:
>On Aug 6, 10:13 pm, alice <al...@fearofdolls.comwrote:
>>
>>
>>
>>
>>
Quote:
>>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.
Closed Thread


Similar PHP bytes