Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I know this is a very commun issue, but as I didn't forget any semicolon, and I declared all variables at the beginning of the script, I'm wondering why this error still throws.

The code is very simple : EDIT :

if (isset($_POST["email"])) 
{
$name=(isset($_POST["name"])) ? $_POST["name"] : ""; 
$email=(isset($_POST["email"])) ? $_POST["email"] : ""; 
$phone=(isset($_POST["phone"])) ? $_POST["phone"] : ""; 
$ext=(isset($_POST["ext"])) ? $_POST["ext"] : ""; 
$website=(isset($_POST["website"])) ? $_POST["website"] : ""; 
$body=(isset($_POST["body"])) ? $_POST["body"] : ""; 
$to = "[email protected]";
$subject = "Message $name from Infiniscale Website";
$message = "$name sent you a message using the contact form. <br/>";
$message .= "Infos : <br/>";
$message .= "Email : $email <br/>";
$message .= "Phone : $phone <br/>";
$message .= "Ext : $ext <br/>";
$message .= "Website : <a href=\"$website\">$website</a> <br/><br/>";
$message .= "Message: $body <br/>";
$from = "[email protected]";
$headers = "From: " .  $from;
mail($to,$subject,$message,$headers);
return "Attempted Mail Send.";
}
else
{
  return false;
}

The form is sended, and the "Attempted Mail Send." message showed. But I don't receive any email in my mail box, while I know the mail server is working.

share|improve this question
up vote 2 down vote accepted

You need to escape the double quotes in your message, so instead of:

$message = "Website : <a href="$website">$website</a> <br/><br/>";

You would need to do

$message = "Website : <a href=\"$website\">$website</a> <br/><br/>";

For all parts of the message that contain double quotes.

share|improve this answer
    
thanks, this caused the error – Romainpetit Oct 10 '11 at 8:10
    
yop but before closing the topic by doing so, did you see the edit i made ? – Romainpetit Oct 10 '11 at 8:15
    
Check to make sure it's not getting trapped in a spam folder and that PHP has the correct path to the sendmail service. – Nexerus Oct 10 '11 at 8:18

@Nexerus is correct. Can also use :

$message = "Website : <a href='".$website."'>$website</a> <br/><br/>";
share|improve this answer
    
It is just a edited answer of Nexerus. You can make a comments on Nexerus' Answer. Try to be honest... – Tareq Nov 20 '11 at 10:15
    
@Tareq you are absolutely right! – Walid Hossain Nov 20 '11 at 10:16
    
Nexerus was edited his post later. @Tareq please see the Duke's comments which was "thanks, this caused the error". I think Nexerus edit his post then. At first he has only one option. This is not my fault. – Ariful Islam Nov 20 '11 at 10:32
    
@WalidHossain Please see the above comments. A down vote(-) can destroy your life. – Ariful Islam Nov 21 '11 at 11:49
    
@Arif Let me give you +1 :) – codesnooker Sep 15 '13 at 22:30

I think the header is must be separated by carriage return and new line"\r\n". and your header like this $header="From:".$from . "\r\n" ;

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.