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
Sending Message in Telegram Bot With Images
Check If Class Property Is Not Null Before Calling Any Public Class Method
How to Get Values of Checkbox Array in Laravel 5
Php Adding 15 Minutes to Time Value
How to Get Filename from a Variable (Url) in PHP
Php Session Lost After Redirect
How to Implement Basic "Long Polling"
How to Remove Duplicate Values from a Multi-Dimensional Array in PHP
How to Get the Client Ip Address in PHP
Send Email Using the Gmail Smtp Server from a PHP Page
How to Use Return Inside a Recursive Function in PHP
How to Send an Email Using PHP
Transposing Multidimensional Arrays in PHP
How to Get a Youtube Video Thumbnail from the Youtube API
Warning: MySQL_Fetch_Array(): Supplied Argument Is Not a Valid MySQL Result