Hi there,
I am using mail (); to send some form info. The script works, but I never recieve the email. Here is the code:
<?php
$Fname = $_POST['Fname'] ;
$Lname = $_POST['Lname'] ;
$Email = $_POST['Email'] ;
$Subject = $_POST['Subject'] ;
$Message = $_POST['Message'] ;
if ( $Fname == "" OR $Lname == "" OR $Email == "" OR $Subject == "" OR $Message == "" ) {
header( "Location: /error_form.html" ) ;
}
else {
mail( "[email protected]", "Feedback Form: $Subject", $Message, "From: $Fname $Lname <$Email>" ) ;
}
?>
<load of html and php echo () that confirms the message was sent>
When the form is submitted it goes through the motions (ie. redirects the browser to error_form.html if some fields are incomplete) and also sends the confirmation html that is defined under the PHP. However, I never recieve the email. I have checked the address (it is valid) and of course no errors occur as it works. Have I got some syntax issues? The weird thing is that the exact same thing works fine on a webserver running PHP v. 4.1.2.
I am guessing there are version issues? I checked PHP.net but couldn't find anything to suggest I am off the mark...
Thanks in advance,
- TatlarOriginally posted by tatlar
When the form is submitted it goes through the motions (ie. redirects the browser to error_form.html if some fields are incomplete) and also sends the confirmation html that is defined under the PHP. However, I never recieve the email.
if the html works that is under the php and you don't get any errors that the mail function failed? well that is not right. it shouldn't be a version problem bu tmay be a server problem.
I would, just to rule out any issues with syntax, make the subject and message and headers, variables.
$subject = "Feedback Form:". $Subject;
$header = "From: $Fname $Lname <$Email>";
mail( "[email protected]", $subject, $Message, $header);
usually the header is your return email not theirs.
you could also do a check.
if(!mail( "[email protected]", $subject, $Message, $header)){
echo "mail not sent, had an error";
exit;
}
also just notice that you semi-colon was a space away from the end, sometimes that could be a problem so make sure it is right next to the ) on the end of the mail function.thanks scoutt - I will test it out now.
- Tatlar
I am using mail (); to send some form info. The script works, but I never recieve the email. Here is the code:
<?php
$Fname = $_POST['Fname'] ;
$Lname = $_POST['Lname'] ;
$Email = $_POST['Email'] ;
$Subject = $_POST['Subject'] ;
$Message = $_POST['Message'] ;
if ( $Fname == "" OR $Lname == "" OR $Email == "" OR $Subject == "" OR $Message == "" ) {
header( "Location: /error_form.html" ) ;
}
else {
mail( "[email protected]", "Feedback Form: $Subject", $Message, "From: $Fname $Lname <$Email>" ) ;
}
?>
<load of html and php echo () that confirms the message was sent>
When the form is submitted it goes through the motions (ie. redirects the browser to error_form.html if some fields are incomplete) and also sends the confirmation html that is defined under the PHP. However, I never recieve the email. I have checked the address (it is valid) and of course no errors occur as it works. Have I got some syntax issues? The weird thing is that the exact same thing works fine on a webserver running PHP v. 4.1.2.
I am guessing there are version issues? I checked PHP.net but couldn't find anything to suggest I am off the mark...
Thanks in advance,
- TatlarOriginally posted by tatlar
When the form is submitted it goes through the motions (ie. redirects the browser to error_form.html if some fields are incomplete) and also sends the confirmation html that is defined under the PHP. However, I never recieve the email.
if the html works that is under the php and you don't get any errors that the mail function failed? well that is not right. it shouldn't be a version problem bu tmay be a server problem.
I would, just to rule out any issues with syntax, make the subject and message and headers, variables.
$subject = "Feedback Form:". $Subject;
$header = "From: $Fname $Lname <$Email>";
mail( "[email protected]", $subject, $Message, $header);
usually the header is your return email not theirs.
you could also do a check.
if(!mail( "[email protected]", $subject, $Message, $header)){
echo "mail not sent, had an error";
exit;
}
also just notice that you semi-colon was a space away from the end, sometimes that could be a problem so make sure it is right next to the ) on the end of the mail function.thanks scoutt - I will test it out now.
- Tatlar