2016-07-25

Although you’d think email forms would come preconfigured to work successfully in all environments, you’d be surprised how often they’re poorly configured by default. There’s a number of very particular aspects to the configuration of contact forms that need to be set precisely in order to work successfully both with our hosting and more generally in the modern world of email.

In the settings and examples below we’re going to be using the name Random Visitor and email address randomvisitor@gmail.com as our sample data to represent the visitor to your website that is submitting the form. We’ll also be using the to address of info@mywebsite.com, which is where contact form submissions will be sent.

Important for users of Gravity Forms: Despite being a premium (paid) plugin, they do not support the multi-part standards required for normal email communications with an HTML message body. It is strongly recommended to not use Gravity Forms. If you absolutely must use Gravity Forms, you will need to disable HTML messages such that it only sends plain text. Note that this change requires basic coding knowledge to implement.

From and Reply-To Headers

The first setting that is often misconfigured is the “From” header.  Most people will configure their website’s contact form to have the messages coming from the email address that the submitter entered in the form, such as randomvisitor@gmail.com. However this is bad practice, and will usually cause messages to not be delivered!

The reason why this can cause delivery issues is because it often clashes with SPF records. You can read a whole bunch about how SPF records work here, but the general idea is that SPF prevents email forgery by comparing the email address of the sender against the server the email is coming from. If the server is approved, then it’s probably a message coming from the sender and not spam pretending to be from them.

Why then, you might ask, does SPF checking have a problem with using randomvisitor@gmail.com as the From address?

When your email server receives the message send via the contact form, it checks gmail.com for its SPF record, which specifies servers that are allowed to send emails on behalf of @gmail.com email addresses. Since the server your website is hosted on is not an approved sender for @gmail.com addresses, it will fail the test and thusly the message is either dropped or filtered to spam.

The solution is actually quite simple! Set the “From” address to an email address that is hosted on your server. For example we often use wordpress@mywebsite.com. (Be sure to replace mywebsite.com with your actual website’s domain, no www).

Then to ensure that when you reply to these emails, the replies actually go to the person who submit the form, you need to set the Reply-To header to the submitter’s email address. With some contact form plugins, you can simply enter this in a Reply-To field, but with others you need to add it to an “Additional headers” field. Here’s a couple examples:

Contact Form 7 has an ‘Additional Headers’ field. Enter: Reply-To: [your-name] <[your-email]>

Gravity Forms has a Reply-To Field. Enter: {Name (First):1.3}{Name (Last):1.6} <{Email:2}>

Note that [your-name] and [your-email] are default tags that Contact Form 7 uses as a placeholder; if you’ve changed the name of the tag, be sure to put in the correct placeholder there. The same is true for {Name (First):1.3} and {Email:2} when using Gravity Forms — be sure to use the correct placeholder values for your particular form.

Non-Local Email

If your email is not hosted with us and instead you have it managed elsewhere (E.g.: Gmail, Hotmail, BellAliant, Eastlink), for best delivery you’ll need to either:

a) configure your contact form to use your email provider’s SMTP service, or

b) configure your SPF record to allow your web hosting server to send email on behalf of your domain

a) Use 3rd party SMTP

Unfortunately we can’t provide direction here for the correct settings to use for an external mail service (as they’re all quite different), but we can show you how to get to the point of entering those settings for specific web applications.

WordPress: The WordPress SMTP plugin will allow you to enter the SMTP details for your mail provider so that all messages sent via WordPress will now go through their servers rather than being sent locally from the server where your website is hosted. It also comes with pre-configured values for Gmail and other common providers.

Magento: The SMTP Pro Email plugin has worked very well for us. Install the plugin using their guide, then configure it to use common email providers like Gmail or custom SMTP credentials for all emails leaving Magento.

If you’re using another application and have found a solution for using 3rd party SMTP providers, please let us know in the comments below!

b) Adjust your SPF Record (advanced)

If you’d prefer not to have to configure your web application / CMS to send emails through your correct email server, you also have the option of allowing your web server to send mail on behalf of your domain. It’s important to note that if your DNS is hosted with us, in most cases we have already configured this for you.

To get started, log in to the control panel of the company where you have your DNS hosted and find the record of type TXT or SPF that begins with: v=spf1

Edit the record by adding immediately after the v=spf1:

+a

Make sure there is one space character before and after this new addition, then save your DNS settings. The change could take up to 24 hours to complete, but realistically it should be live within an hour.

Adding +a to your SPF record means that the server with the IP address that matches the DNS record of type “A” for your domain (not a subdomain) is allowed to send email on behalf of your domain. This will only work if your website is currently live on our hosting.

Using the correct configuration for your forms, as described above, will ensure accurate and successful sending of all messages through the forms on your website.

Show more