Home Ask Login Register

Developers Planet

Your answer is one click away!

Matarishvan February 2016

PHP mail going to spam folder in Gmail

My code looks like this

$to = "mymailid@gmail.com";
$subject = "sample subject";
$body = "<div> hi hi .. </div>";
$headers = "Reply-To: The Sender <mymailid@gmail.com>\r\n"; 
$headers .= "Return-Path: The Sender <mymailid@gmail.com>\r\n";
$headers .= "From: The Sender <mymailid@gmail.com>\r\n"; 
$headers .='X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

mail($to, $subject, $body,$headers)

I have sent the suitalbe header in my mail function. Everytime when i run this code, my mail will go to the spam folder in my gmail account.. How do i avoid my mail going to spam folder?


Vijay Sai Chaudary February 2016

It can fixed by passing complete header information informing the mail provider as the sender is a trusted domain (https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail) also some DNS settings involved.
You can find the detail information here:



Post Status

Asked in February 2016
Viewed 3,686 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life