People often find their emails going to spam. Often people experience this after enabling Cloudflare WAF or simply switching DNS name servers. Sometimes this happens out of the blue. There are many reasons this can happen:
1. SPF record not set
SPF record authorizes your server to use the domain name you are sending for.
2. SPF record incorrect
Make sure to include the correct records and IP addresses if necessary. If your domain is example.com make sure that the server that is
sending mails is included and that there is a valid A record for this domain.
3. Mail software incorrectly configured
Make sure that the domain name you are sending the mail for is configured in the mail software. If you are using postfix you can find this configuration in /etc/postfix/main.cf .
myhostname = example.com
4. Mail content
Make sure your mail contains allowed characters and passes any spam filters. A lot of html and no actual content might be suspicious.
5. Check if you are in any blacklists.
Contact your smtp provider and find out if they notice any issues.
6. DKIM and DMARC
If there are no issues with either of the previous points you can try increasing your mail authentication by setting up DKIM and DMARC. We will explore these records in another post.
TIP
There is a great service that helps identify issues with mail configuration - https://www.mail-tester.com/.
After sending a mail to a designated address it will pin point issues and even offer suggestions for SPF records, mail content or other configuration issues.