Mails generated in PHP going to Spam (in Gmail only)

123 Views Asked by At

I am using Xenforo and the following script to send mail

<mail:subject>
    {{ phrase('user_email_confirmation_subject', {
        'boardTitle': $xf.options.boardTitle
    }) }}
</mail:subject>

{{ phrase('user_email_confirmation_body_html', {
    'username': $user.username,
    'board': '<a href="' . link('canonical:index') . '">' . $xf.options.boardTitle . '</a>'
}) }}

<p><a href="{{ link('canonical:account-confirmation/email', $user, {'c': $confirmation.confirmation_key}) }}" class="button">{{ phrase('confirm_your_email') }}</a></p>

When I use this script, the mail is going to spam for Gmail only.

How can I prevent email going to spam?

1

There are 1 best solutions below

0
On

Email deliverability can be a nightmare when you're hosting your own email server.

Regardless of my advice here, it is still common to find your emails in either Spam or Promotions in Gmail. Gmail and Microsoft are always the hardest to deliver to.

First thing you want to do is go to mail-tester.com and register a new account on your forum using the email they provide. Wait a few minutes and then check your score. It will tell you how spammy your email is and provide solutions to the problem.

1) Make sure you have SPF, DKIM and DMARC setup

2) If you're using shared hosting that doesn't allow these things then you need to switch hosts

3) Check the blacklists, if you're on a blacklist apply to get removed. If you're on shared hosting this is not possible. Make sure you check the domain name and the email IP address, you can find the email server IP address from the email headers.

4) If the spam risk factor for your email server's IP is too high, get a new server.

5) Always warm up any self hosted email server, start by sending 20 emails a day for a week, then 50 for a week, then 100 2 weeks, then 500 for a month. After a 2 month period you're fine to start sending as many as you want (within REASON!). For a forum, just limit it to account registration emails only and then enable the other emails as time goes on.

Most people don't want your emails anyways, so limit the number of emails to only those that users want.

Alternatively sign up with SendGrid or Mailjet or a similar paid smtp provider and this will all be taken care of for you.