I know there is a few of these posts already up, and I read through them, but was unable to find the solution to my problem. The PHP and HTML looks good so I am not exactly sure why I am not receiving any email from the submitted contact form.
Here is the PHP:
<?php
$Fname = $_POST ['Fname'];
$Lname = $_POST ['Lname'];
$email = $_POST ['email'];
$message = $_POST ['message'];
$to = 'myName@mywebsite.com';
$subject = 'Contact From My Website';
$msg = " First Name: $Fname/n" .
"Last Name: $Lname/n" .
"Email: $email/n" .
"Message: $message";
mail ($to, $subject, $msg,"From: " . $Fname . $Lname);
$confirm = "Thank you for contacting us! Please allow 48 hours for a representative to respond. Click <a href='contact.php'>here</a> to return to the previous page.";
?>
And here is the HTML form code:
<form id="form1" name="form1" method="post" action="send.php">
<tr>
<label><td width="160px" class="labels">First Name: </td>
<td class="input"><input type="text" name="Fname" id="Fname"/></td>
</label>
</tr>
<tr>
<label><td class="labels">Last Name: </td>
<td class="input"><input type="text" name="Lname" id="Lname"/></td>
</label>
</tr>
<tr>
<label><td class="labels">Email: </td>
<td class="input"><input type="email" name="email" id="email"/></td>
</label>
</tr>
<tr>
<label><td class="labels">Message: </td>
<td class="input"><textarea name="message" id="message" cols="30" rows="5"></textarea></td>
</label>
</tr>
<tr>
<td class="labels"><input type="submit" name="submit" id="submit" value="Submit"/></td>
</tr>
</form>
Any help would be greatly apreciated
Add
$headers = "From:" . $Fname . $Lname;
and use this:
mail ($to, $subject, $msg, $headers);
"From" should not include the name, instead it should include the from email address.
So, instead of
"From: " . $Fname . $Lname
You should be doing
"From: ". $myEmail
Here's a valid header from the php manual:
$headers = 'From: webmaster@example.com' . "
" .
'Reply-To: webmaster@example.com' . "
" .
'X-Mailer: PHP/' . phpversion();
I guess Puggan and Fred get credit for this answer as-well, since they have posted out the obvious but not yet made it an answer.
You should also make sure that the id of the message labels match to $_POST['msg'], so you should not be using 'msg' in one place and 'message' in another.
FYI: skip the spaces ' ' between the function name and the parameter arguments. i.e.
$_POST ['stuff'];