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
PHP mail function goes to junk
If you are using a shared server than probably the score for that server is bad. If you are using your own server probably it's neutral but sometimes will go to spam because the server does not have a good reputation and depends how each email provider see that email.
Best solution I see it's to integrate a mailing service. In this way they promise that emails will not go to spam.
I don't know how many emails you are sending / month.
There are some that offer free email / month. Depends on volume.
For example:
- SendGrid - 12.000 free emails / month and they have official
PHP library . Tested no problem with spam. - MailGun - 10.000 free
emails / month. Did not test this one but it's from rackspace - Mandrill - no free emails, part of mailchimp. Tested no problem with spam.
- Amazon SES - 62.000 free emails / month for first year if you use free tier. Tested no problem with spam.
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
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!";
}
?>
Related Topics
File_Get_Contents(): PHP_Network_Getaddresses: Getaddrinfo Failed: Name or Service Not Known
Parentheses Altering Semantics of Function Call Result
Prevent Sent Emails Treated as Junk Mails Using PHP Mail Function
Get Absolute Path of Initially Run Script
Html - Change\Update Page Contents Without Refreshing\Reloading the Page
PHP - How to Merge Arrays Inside Array
How to Remove a Variable from a PHP Session Array
How to Retrieve Request Payload
Laravel - Session Store Not Set on Request
Calculating Days of Week Given a Week Number
Why Are $_Post Variables Getting Escaped in PHP
Add a Custom Attribute to a Laravel/Eloquent Model on Load
Sending Multiple Iphone Push Notifications + Apns + PHP