I'm making a simple PHP mail sender to send an image to multiple addresses at a time. Don't know why, but the emails keep on arriving at the SPAM folder, no matter what email manager I send them...
Here's how I call the PHP mail sender file:
$.ajax({ url: 'mail_sender.php?receiver=' + receiver + '&=lang' + lang,
success: function (response)
{
console.log('Mails ' + response);
}
});
And this is my PHP file structure:
<?php
// Reciever
$_to = $_GET["receiver"];
$_lang = $_GET["lang"];
// subject
$subject = 'My Subject';
// sender
$sender = "sender@sender.es";
// message
$message = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
<META name="generator" content="HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org">
<TITLE></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<img src='."https://www.mysite.es/demo/img/emails/imagen_".$_lang.".jpg".' />
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = "Reply-To: <sender@sender.es> \r\n";
$headers .= "Return-Path: <sender@sender.es>" . "\r\n";
$headers .= "From: <sender@sender.es>" . "\r\n";
$headers .= "Organization: My organization" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
$headers .= "X-Priority: 3" . "\r\n";
$headers .= "X-Mailer: PHP/". phpversion();
// Mail it
$ret = mail($_to, $subject, $message, $headers);
if ( $ret == '' || $ret )
{
echo $ret;
}else{
echo $ret;
}
?>
Can anyone give some clues?
Thank you very much!
Try sending a plain text email instead of HTML (if that suits your needs). In my experience the HTML often triggers spam filters but f you really need to use HTML try to look at some of the email templates that mailchimp uses.
https://github.com/mailchimp/Email-Blueprints
The matter should be the IP of your server. if a provider recieves much mails from the same IP it is considered as spam, no matter what comes.
There doesn't seem to be anything technically wrong with your code, and there could be many reasons your emails are being rejected by spam filters, but my guess would be that your email content is just an image. This is a strong indicator to spam filters. Try to design your emails using text, and only use images to support your information.
You should consider testing your emails through spamassassin which will give your email a spam score based on a given set of rules.
Many email providers use these kind of tools.
Edit: http://wiki.apache.org/spamassassin/StartUsing might be a good place to start.