SMTP emails go to spam


For sending emails from OJS 3.0.2, we use own email server with DKIM and SPF. For some period we have been using direct SMTP email sending. But in this case, it often goes to the recipient’s spam folder. Direct emails, bypassing OJS, are received normally. As are those, sent by PHP mail() function. Moreover, once activated, we cannot turn off SMTP. It works even after commenting out appropriate lines in the config file.
From where I can start a search of the problem’s roots?

Hi @Vitaliy,

When messages are sent to a spam folder, the headers inside the message often indicate what caused it to be flagged. Use the “View Message Source” tool (details will depend on your email client) to see if you can find them.

Alec Smecher
Public Knowledge Project Team

Just have looked at a header. All seem to be normal.
SPF: Pass
DKIM: Pass

As for me, two issues may look suspiciously:

  • HTML tags

      Content-Type: text/plain; charset=us-ascii`
      Is this email in spam?
      Journal Title
      Content-Type: text/html; charset=us-ascii
      <p>Is this email in spam?</p><br/><p><br> ________________________________________________________________________<br> <a href="https://.../index.php/psp">Journal Title</a></p>
  • Absence of DMARC. Is it crucial? Didn’t get around with it. Once again, direct emails are received without problems, most of the cases.

For now have tested with Gmail, Yahoo, and our regional email provider. Problems only with the first.

Also, according to this line: X-PHP-Originating-Script: 0:class.phpmailer.php SMTP, nonetheless, can be turn off. And emails still go to spam after this

After configuring DMARC and passing this test nothing changed.

       dkim=pass header.s=dkim header.b=QevwwcEp;
       spf=pass ( domain of designates 333.33.33.33 as permitted sender);
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE)

After headers’ line by line check, comparing with those headers from emails, that not go to spam in Gmail, I found only one difference. Absence, in my case, of 'X-Mailer`. Maybe there is a reason to add it?

As for Yahoo. All emails are passing spam filters if using PHP mail(). But not SMTP or direct sending. Those headers are identical, except of this line: X-PHP-Originating-Script: 0:class.phpmailer.php

I am utterly confused.

As my final move, I added PTR record to the domain.
If SMTP on:

  • Gmail places emails as appropriate and even marks as “important”. But not in all cases.

  • Yahoo mail places them to spam.

If SMTP off:

  • Gmail places emails to spam.

  • Yahoo treats them as needed.

I give up :confused:

Maybe this info would be interesting for those, who have own mail server.
Aftet searching this issue on the internet I have discovered that in regard to gmail it is not enough to have DKIM, DMARC, and PTR for own email server.
If someone wants email not to be marked as a spam by gmail, he/she need to proof Google that email server is not sending any spam.
Usually it requies several month and good will of email receivers (they must mark email as not spam).

Interestingly, but when email is sent by php mail() function, it bypasses Gmail and Yahoo mail spam filters. Neverheless DKIM need to be valid. Don’t know really why it is a case. Maybe it was done deliberately for some reasons. Or it is breach in
theirs spam filters.

So mail() function could be even more better option than direct SMTP for described reason.