SPF Macro Guide

Overview of SPF macros

Using SPF, you can specify which IP addresses are authorized to send emails from a mail server. Many of the directives you can use allow you to specify a domain name, but here SPF comes with an extra feature: Macros.

Macros allow you to insert dynamic values into the values of SPF directives, which can be used for e.g. per-user authentication and more. This guide will go through all macros, along with some examples.

The mechanisms and modifiers that allow macros are: include, a, mx, ptr, exists, redirect and exp.

List of macros

Transformers

SPF macros can be transformed in a few different ways, by adding another character after the macro letter.

Explanations

SPF allows you to set custom error messages in case of failed validations using the exp modifier. The message is retrieved from the TXT records of the domain name defined by the modifier. This error message also supports macros, and has extended support for a few more than the ones above:

SPF tools:

SPF Validator ToolSPF Creator Tool