Sender Policy Framework (SPF) is an open standard aimed at preventing sender address forgery. This article describes how SPF is configured for use with SendGrid.
SPF attempts to prevent email sending abuse by ensuring that the IP address from which a message was sent is authorized to send mail on behalf of the domain in the email’s Envelope From or
For more information about From addresses and email, see our article on email spoofing.
To understand SPF, it may help to understand how email traffic is handled when SPF is added to the process. Imagine an email server receives a message and checks the message's
email@example.com. To perform an SPF check, the following steps take place:
When you complete Domain Authentication, automated security is enabled by default. Automated security handles your SPF and DKIM records for you. Twilio SendGrid provides CNAME records that you need to add to your DNS records. This allows you to add dedicated IP addresses and make other account updates without having to manage your SPF records manually.
To disable this behavior, uncheck Use automated security when completing the domain authentication process. With automated security disabled, Twilio SendGrid provides you with TXT records like those discussed in this documentation rather than CNAME records.
If you have an SPF record set for your domain already, you must add a unique alphanumeric string before the
all mechanism of this record in order to authenticate mailings through your SendGrid account. If you do not have an existing SPF record for your domain, you must create a TXT record with the value provided to you during the domain authentication process. Each SendGrid account gets a unique SPF TXT record to authenticate their outbound mailings. An example of such a record is:
v=spf1 include:u123456.wl.sendgrid.net -all
In this example, we have a unique SPF record for the authorization of outbound mail for a SendGrid account. A
-all inclusion versus an
~all inclusion indicates that this SPF record is the only record used to authenticate mail for your domain. Make sure to include any other authorized sender into this SPF record if you need to authenticate mailings from other sources.
Do not create more than one SPF1 record for a given domain. If more than one SPF1 record exists for a domain, you will want to merge any additional SPF records into one SPF record. You also cannot have more than 10 DNS lookups in your single SPF record.
If you already have an SPF record for your domain, you need to add your SendGrid account's unique SPF inclusion into your existing record.
For example, say your existing record looks like this:
v=spf1 a mx include:\_spf.google.com include:spf.protection.outlook.com -all
You would need to add the SendGrid lookup at the end of the string, before the
all mechanism, like so:
v=spf1 a mx include:\_spf.google.com include:spf.protection.outlook.com include:u826348.wl.sendgrid.net -all
If you would rather not include SendGrid's SPF hostname lookup in your record, or perhaps you have too many already, you can also choose to give permission to a specific IP address to send mail for your domain. This is accomplished using the
ip4 mechanism within your SPF record.
You can choose to specify your dedicated IP address as a lookup, which means that only mail coming from that particular IP address will be considered a permitted sender within SendGrid for that domain. An example of this looks like:
v=spf1 a mx include:\_spf.google.com include:spf.protection.outlook.com ip4:18.104.22.168 -all
If you wish to add multiple
ip4 lookups (if you have an account that sends from multiple dedicated IPs, for example), add them to your record separated by spaces. Unlike with
include:hostname lookups, a SPF1 record can have any number of
For more information on official SPF best practices and syntax, you can find the SPF specification at www.openspf.org.
Let us know how we’re doing! Please rate this page:
Please note, we cannot resolve account and login issues reported on GitHub. Contact support for account assistance.
Thanks for helping us improve our docs!