Eslam Zedan

28 Feb 2022

PHP mail function goes to spam not inbox

PHP & Mysql


I want to send an email using the PHP mail function not SMTP (I know that is not good practice but the Client request that).

the emails go to the junk/spam folder is there any way to make it goes to the inbox as a normal email?

I tried the solution here //

but it goes to junk 

here is my code 

$to_email = '';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail function';

$headers = "From:\r\n";
$headers .= "Reply-To:\r\n";
$headers .= "Return-Path:\r\n";
$headers .= "CC:\r\n";
$headers .= "BCC:\r\n";

any help please



28 Feb 2022


It seems like your SMTP server is not configured well.

To be aware of spam emails, the latest mail clients will check who is sending an email. It uses a test like Reverse-DNS-Lookups.

Your PHP mail() function will fail with this test.


Solution: You can use PHPMailer-Class and configure it to use SMTP-auth along with a well configured, dedicated SMTP Server (Recommended AWS server) and your problems will be fixed 100%.


Eslam Zedan

28 Feb 2022

My clint does not want me to use SMTP so I am using native php mail function 

© 2024 Copyrights reserved for