I am trying to send an email using PHP from a free hosting account on Hostinger (hostinger.co.uk).
Here is my code:
<?php
if(isset($_POST['submit'])){
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
For some reason when i send the email, it doesn't come through to my gmail account. It's not even in spam.
I reckon this has something to do with the headers and more specifically my from address - since if i change the from email address to the below, then i receive the email.
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
Please can someone show me / tell me what i am doing wrong here and why gmail doesn't like the other from address?
Thanks in advance