How to Prevent Mails Sent Through PHP Mail() from Going to Spam

How do I prevent mails sent through PHP mail() from going to spam?

You must to add a needle headers:

Sample code :


$headers = "From: myplace@example.com\r\n";
$headers .= "Reply-To: myplace2@example.com\r\n";
$headers .= "Return-Path: myplace@example.com\r\n";
$headers .= "CC: sombodyelse@example.com\r\n";
$headers .= "BCC: hidden@example.com\r\n";

if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>

How to prevent mail from going to spam?

$to='example@gmail.com';
$subject='Application Form ';
$message='testing';

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: admin <admin@gmail.com>' . "\r\n";
if(mail($to,$subject,$message,$headers))
{
echo "Mail Successfully Sent..";
exit;
}

It works perfectly to me. You can also use SMTP MAIL instead of this.

PHP mail goes in spam and inbox

Use full headers to avoid spam

http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/

Prevent sent emails treated as junk mails using php mail function

How to avoid my mails sent from PHP mail() being marked as spam?

The php mail() function has nothing to-do with your emails being marked as spam.

That an email is being marked as spam happens on the other end. You can not influence the process much with mail() - as it's the other end.

There can be thousand of reasons why an email is being marked as spam, and as long as you don't know the concrete reason why your email is being marked as spam, you can do nothing against that.

There is a whole industry which makes a living of that btw.

PHP mail() form sending to GMAIL spam

Use this code :

 $to = Email;
$subject = subject ;
$body = "<div> hi hi .. </div>";

$headers = 'From: YourLogoName info@domain.com' . "\r\n" ;
$headers .='Reply-To: '. $to . "\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";
if(mail($to, $subject, $body,$headers)) {
echo('<br>'."Email Sent ;D ".'</br>');
}
else
{
echo("<p>Email Message delivery failed...</p>");
}

sending email via php mail function goes to spam

The problem is simple that the PHP-Mail function is not using a well configured SMTP Server.

Nowadays Email-Clients and Servers perform massive checks on the emails sending server, like Reverse-DNS-Lookups, Graylisting and whatevs. All this tests will fail with the php mail() function. If you are using a dynamic ip, its even worse.

Use the PHPMailer-Class and configure it to use smtp-auth along with a well configured, dedicated SMTP Server (either a local one, or a remote one) and your problems are gone.

https://github.com/PHPMailer/PHPMailer



Related Topics



Leave a reply



Submit