0

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.

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

yop but before closing the topic by doing so, did you see the edit i made ?
Check to make sure it's not getting trapped in a spam folder and that PHP has the correct path to the sendmail service.
0

@Nexerus is correct. Can also use :

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

4 Comments

It is just a edited answer of Nexerus. You can make a comments on Nexerus' Answer. Try to be honest...
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.
@WalidHossain Please see the above comments. A down vote(-) can destroy your life.
@Arif Let me give you +1 :)
0

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" ;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.