This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.


You can use special variables in several places:

The variables that work (almost) everywhere are:

These variables work almost everywhere else except in Dovecot-auth (userdb queries/templates):

These variables work only in Dovecot-auth and login_log_format_elements setting:

These variables work only in Dovecot-auth:

These variables work only in login_log_format_elements setting:

These variables work only in deliver_log_format setting:

These variables work only in auth_policy_request_attributes setting:


You can apply a modifiers for each variable (e.g. %Us = POP3):

You can take a substring of the variable by giving optional offset followed by '.' and width after the '%' character. For example %2u gives first two characters of the username. %2.1u gives third character of the username.

If the offset is negative, it counts from the end, for example %-2.2i gives the UID mod 100 (last two characters of the UID printed in a string). If a positive offset points outside the value, empty string is returned, if a negative offset does then the string is taken from the start.

If the width is prefixed with zero, the string isn't truncated, but only padded with '0' character if the string is shorter. For example %04i may return "0001", "1000" and "12345". %1.04i for the same string would return "001", "000" and "2345".

If the width is negative, it counts from the end, for example %0.-2u gives all but the last two characters from the username. (v2.2.13+)

The modifiers are applied from left-to-right order, except the substring is always taken from the final string.


Since v2.2.33 it's possible to use conditionals in variable expansion. The generic syntax is


Each field can contain another variable expansion, facilitating for nested ifs. If some field refers to another field, it must use either %v or %{value} syntax.

Escaping is supported, so one can have values like \%{value} that will not get expanded, or literal : and ; in the expression.

Spaces and quotes are fully supported.

Following operators are supported




NUMERIC equality


NUMERIC inequality


NUMERIC less than


NUMERIC less or equal


NUMERIC greater than


NUMERIC greater or equal


String equality


String inequality


String inequality


String inequality


String inequality


String inequality


Wildcard match (mask on value2)


Wildcard non-match (mask on value2)


Regular expression match (pattern on value2, extended POSIX)


String inequality (pattern on value2, extended POSIX)

None: Variables (last edited 2019-04-20 08:37:14 by AkiTuomi)