I am using php mail()
to send email from my website. But I am facing strange behaviour.
$headers = "From: Saurabh Sharma <no-reply@example.com>\r\n";
$headers .= 'Reply-To: ' . $email . "\r\n";
$headers .= "Return-Path: me@example.com\r\n";
$headers .= "Organization: Saurabh Sharma\r\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "MIME-Version: 1.0" . "\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
But all the mails are landing in spam.
Also, I have added a rule on the server to send the copy of every mail to my personal email on gmail. I am able to receive the mail on gmail when I use php mail()
(in spam) but can't see any mail on RoundCube on my server even if the receiving address is of my domain email address i.e me@example.com
but I receive only the copy on gmail.
Also, If I send mails to/from Roundcube to my Gmail and vice versa, mail always lands in inbox in Gmail and Roundcube also shows the mail in inbox.
But strange things are happening in php mail();
The major issue is that email is not received on me@example.com but I can see the copy on Gmail.
Am I doing something wrong in headers?