Question: I am not receiving emails from this contact form, but the message seems to sending okay and it also redirects me to the sent page.
I don't have access to the server only via FTP.

---

PHP

---

```
<?php
$to = 'test@gmail.com';
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$body = <<<EMAIL

<html>

<p><h3>Email Submited From Website.</h3></p>

<p><strong>Name:</strong> $name</p>
<p><strong>Email:</strong> $email</p>
<p><strong>Subject:</strong> $subject</p>
<p><strong>Message:</strong> $comment</p>

</html>

EMAIL;

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: test email' . "\r\n";
$headers .= 'From: <website@mt.co.uk>' . "\r\n";
//$headers .= 'Cc: noreply@example.com' . "\r\n";
//$headers .= 'Bcc: noreply@example.com' . "\r\n";

if ($_POST['submit']){
mail($to, $subject, $body, $headers);
header ("Location: message-sent.php");
die();
} else {
header ("Location: message-failed.php");
die();
} 
?>

```

Answer: 
Change this:

```
$headers .= 'To: test email' . "\r\n";
$headers .= 'From: <website@mt.co.uk>' . "\r\n";

```

To this:

```
$headers .= "To: $to <test email>\r\n"; 
$headers .= "From: website@mt.co.uk <website@mt.co.uk>\r\n";

```

Also, you need to sanitize the subject and body of the email so that the email arrives, but this will usually be reflected in the results after email() reports a success, in that case the email will bounce, go to the spambox, or simply be refused.
If your hosting provider doesn't have an email server, you could try to use a free email server and phpMailer. <https://github.com/PHPMailer/PHPMailer>