When sending emails to Gmail they go to Spam when I have perfect mail server

1

I am using iRedMail and I have a perfectly setup of mail server.

www.mail-tester.com gives me 10/10.

However when I use this code to sent automatic emails:

$subject = "Subject here";
$message = "Hello dear $name,<br>
We would like to inform you that the service <b>$service</b> is cancelled!<br><br>
You will no longer be invoiced for this service at the first of the month.<br>
Please if you have any questions do not hesitate to contact us!<br>";


    $headers = 'From: Order Received <noreply@MYDOMAIN.com>' . "\r\n" .
                'MIME-Version: 1.0' . "\r\n" .
                'Content-type: text/html; charset=UTF-8' . "\r\n" .                         
                'Reply-To: Order Received <noreply@MYDOMAIN.com>' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();

$subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";               

mail($email, $subject, $message, $headers); 

Note that I have replaced MYDOMAIN.com with my actual domain. Here I place an edited sample.

Do you have any idea why my emails go to SPAM when I am not in any blacklists ?

Venelin Vasilev

Posted 2016-03-29T18:35:36.173

Reputation: 119

1Why are you base64 encoding the subject line? – DavidPostill – 2016-03-29T18:49:15.240

Answers

0

There are a lot of possible reasons your email could be being dropped. Spam filtering looks at a lot of different elements. Without knowing a lot more details (particularly your domain name, IP address, and message contents) it is only possible to guess what may be causing your problems.

In addition to encoding the subject line as DavidPostill suggested -

  • You may also want to drop the X-Mailer line.
  • You appear to be sending an HTML message without a corresponding text version.

s of your email are very important, and probably the most important thing that Spamassassin checks. This is most likely the cause of your problem - but without knowing what the exact text is, no inferences can be made.

davidgo

Posted 2016-03-29T18:35:36.173

Reputation: 49 152

I have updated my question for you to see the exact text. Can you give me any advice now ? – Venelin Vasilev – 2016-03-29T19:27:01.317

A few things jump out from your text, which could be confounding matters - Change "hello dear" to "Hi" in the first line of text. "hello" and "dear" are often associated with Nigerian scam emails. – davidgo – 2016-03-29T19:58:50.497

Unless you are planning on customising the text further, I'd also make the email a "plain text" email - ie drop the html component altogether. (You also have another potential issue that you use the word "cancelled" - GMail might be confusing this email with a Phishing email - eg those "your account has been cancellled, click (fake page) to reset password" type email. – davidgo – 2016-03-29T20:02:37.473

Also, you need to change the subject line to something meaningful. – davidgo – 2016-03-29T20:06:58.670