1

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      = 'xxxxxxxxx@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: customer@novel.com' . "\r\n" .
    'Reply-To: customer@novel.com' . "\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: blux@g.com' . "\r\n" .
    'Reply-To: blux@g.com' . "\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

M.Doe
  • 27
  • 1
  • 2
  • 6
  • Its Gmail Security from spammer so see this solutions [link](http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page) – Samir Nabil Oct 30 '16 at 08:21

1 Answers1

0

Gmail checks if sender is authorized to send mail or not for security reasons. Due to that if you use any email id whose owner has enabled SPF and DKIM it will reject mail. So try using your server name after @ in your from address. You can set reply-to address to any address you like.

Parth Shah
  • 21
  • 3