Mails From EXIM To Gmail Marked As Spam

Sometimes, it becomes more complicated to manage all the mail deliveries in EXIM due to the recipient’s spam filter settings. The server in Gmail often marks emails as spam, constituting the most common issue

Solving Spam mail issues

If your Gmail ever receives the mail in the junk folder, check the email source which will be in the junk folder, and find the received headers in the email.

Solving Spam mail issues

Now, format the SPF TXT record with both IPv4 and IPv6 addresses
v=spf1 a mx
ip4:xxx.xxx.xx.xx
ip6:xxxx:xxx:x:xxx:x:x:x:x –all

But in some cases, the server (EXIM) has a local configuration of both IPv4 and IPv6 addresses. When there is no A record for the IPv4 address we need to add an AAAA record in the server for the IPv6 address, in which the EXIM sends emails in that format by default.

Once you got your TXT and AAAA records configured, test the response with:

dig +short example.com txt (for SPF)

Solving Spam mail issues

dig +short example.com AAAA (for IPv6)

Solving Spam mail issues

Furthermore,

Make sure that there are Reverse DNS entries for both of your IPv4 and IPv6 addresses send another email from the server to yourself and then view the raw source/headers. If you still see that SPF is flagged as none, then try to restart your mail service and check if the TXT record is propagated.

Now, if you see that SPF is flagged as neutral or passed and mail is still considered spam, check whether the EXIM is picking up the right hostname. If EXIM isn’t delivering with the right hostname, edit the EXIM configuration file by manually overriding the primary_hostname.

vi /etc/exim.conf (on cpanel servers; other OSes may differ in the configuration path).

Uncomment the primary_hostname and set it to your server’s primary domain (should be the same as the Reverse DNS entry you added earlier). Restart Exim for the change to take effect. Now, restart the EXIM service.

After following through this entire process, you should see get as like the below image.

Solving Spam mail issues

Wrapping Up

Additionally, to achieve a high volume of email delivery, you should also add a DKIM record.