This page documents PhoenixDKIM, a maintained fork of OpenDKIM. Options may differ from the original.
NAME
opendkim - DKIM signing and verifying filter for MTAs
SYNOPSIS
opendkim [-A] [-b modes] [-c canon] [-d domain[,...]] [-D] [-e name] [-f] [-F time] [-k keyfile] [-l] [-L min] [-n] [-o hdrlist] [-p socketspec] [-P pidfile] [-Q] [-r] [-s selector] [-S signalg] [-t testfiles] [-T secs] [-u userid[:group]] [-v] [-V] [-W] [-x configfile] [-X]
DESCRIPTION
opendkim implements the DKIM standard for signing and verifying e-mail messages on a per-domain basis.
opendkim uses the milter interface, originally distributed as part of version 8.11 of sendmail(8), to provide DKIM signing and/or verifying service for mail transiting a milter-aware MTA.
Most, if not all, of the command line options listed below can also be set using a configuration file. See the -x option for details.
DATA SETS
Many of the command line and configuration file parameters will refer to a "dataset" as their values. This refers to a string that either contains the list of desirable values, or to a file that contains them, or (if enabled at compile time) a database containing the data.
Some data sets require that the value contain more than one entry. How this is done depends on which data set type is used.
Which type is used depends on the format of the specification string. Note that not all of these are necessarily supported for all installations; most of them depend on the availability of a particular third-party library at compile time.
In particular:
|
a) |
If the string begins with "file:", then the remainder of the string is presumed to refer to a flat file that contains elements of the data set, one per line. If a line contains whitespace-separated values, then the line is presumed to define a key and its corresponding value. Blank lines are ignored, and the hash ("#") character denotes the start of a comment. If a value contains multiple entries, the entries should be separated by colons. | ||
|
b) |
If the string begins with "refile:", then the remainder of the string is presumed to specify a file that contains a set of patterns, one per line, and their associated values. The pattern is taken as the start of the line to the first whitespace, and the portion after that whitespace is taken as the value to be used when that pattern is matched. Patterns are simple wildcard patterns, matching all text except that the asterisk ("*") character is considered a wildcard. If a value contains multiple entries, the entries should be separated by colons. | ||
|
c) |
If the string begins with "lua:", it is presumed to refer to a file that contains a Lua script to be executed whenever a query is performed. The key for the query is placed in a global variable called "query", which the called script can then access. The script may return any number of values as required for the type of query being performed. (Requires Lua 5.4; enabled with -DWITH_LUA=ON.) | ||
|
d) |
If the string contains none of these prefixes but starts with a slash ("/") character, it is presumed to be a flat file as described above. | ||
|
e) |
If the string begins with "csl:", the string is treated as a comma-separated list as described in h) below. | ||
|
f) |
If the string begins with "lmdb:", it refers to a directory containing an LMDB (Lightning Memory-Mapped Database) key-value store. (Requires liblmdb; enabled with -DWITH_LMDB=ON.) | ||
|
g) |
If the string begins with "http:" or "https:", the remainder is a URI that is queried with an HTTP GET for each lookup. The lookup key can be inserted into the path using the tokens "{key}" (the whole key), "{d}" (the part before the first colon), and "{s}" (the part after it); substituted values are restricted to the characters [A-Za-z0-9._@-] and percent-encoded. If the path contains no token, the key is appended as "?key=<value>". An HTTP 200 response supplies the value, with its trailing line ending stripped; 404 means "not found"; any other status is treated as an error. Authentication and the per-request timeout are controlled by the HttpAuthToken, HttpAuthHeader, and HttpTimeout options described in opendkim.conf(5). (Requires libcurl; enabled with -DWITH_CURL=ON.) | ||
|
h) |
If the string begins with "vault:", the remainder is treated as a URI to a HashiCorp Vault KV secrets engine: the "vault:" scheme is rewritten to "https:", an "X-Vault-Token" header is added (see VaultToken in opendkim.conf(5), or the VAULT_TOKEN environment variable), and the requested field (see VaultField, default "private_key") is extracted from the JSON envelope of both KVv1 and KVv2 responses. Token substitution, status handling, and the timeout are otherwise identical to the "http:" backend. Alternatively, when the secret carries a selectors array (see VaultSelectorsField in opendkim.conf(5)), a single KeyTable lookup may raise multiple signing requests: the filter emits one DKIM signature for every selector whose validity window contains the current time. This signs with an old and a new selector concurrently during a key rotation (so a verifier passes against whichever DNS record it has yet propagated) and, where selectors of different algorithms are valid, produces both an RSA and an Ed25519 signature. (Requires libcurl; enabled with -DWITH_CURL=ON.) | ||
|
i) |
In any other case, the string is presumed to be a comma-separated list. Elements in the list are either simple data elements that are part of the set or, in the case of an entry of the form "x=y", are stored as key-value pairs as described above. |
OPTIONS
|
-A |
Automatically re-start on failures. Use with caution; if the filter fails instantly after it starts, this can cause a tight fork(2) loop. This can be mitigated using some values in the configuration file to limit restarting. See opendkim.conf(5). |
-b modes
Selects operating modes. modes is a concatenation of characters that indicate which mode(s) of operation are desired. Valid modes are s (signer) and v (verifier). The default is sv except in test mode (see -t below) in which case the default is v.
-c canon
Selects the canonicalization method(s) to be used when signing messages. When verifying, the message’s DKIM-Signature: header specifies the canonicalization method. The recognized values are relaxed and simple as defined by the DKIM specification. The default is simple. The value may include two different canonicalizations separated by a slash ("/") character, in which case the first will be applied to the headers and the second to the body.
-d dataset
A set of domains whose mail should be signed by this filter. Mail from other domains will be verified rather than being signed.
|
-D |
Sign subdomains of those listed by the -d option as well as the actual domains. |
-e name
Extracts the value of name from the configuration file (if any).
|
-f |
Normally opendkim forks and exits immediately, leaving the service running in the background. This flag suppresses that behaviour so that it runs in the foreground. |
-F time
Specifies a fixed time to use when generating signatures. Ignored unless also used in conjunction with -t (see below). The time must be expressed in the usual UNIX time_t (seconds since epoch) format.
|
-g |
Skip walking the SigningTable for any missing keys in the KeyTable. This overrides the config option CheckSigningTable in opendkim.conf(5). | ||
|
-G |
Force walking the SigningTable for missing keys in the KeyTable on config load, overriding the CheckSigningTable config file option. In conjunction with -n option described below, you can perform the check only. |
-k keyfile
Gives the location of a PEM-formatted private key to be used for signing all messages. Ignored if a configuration file is referenced that defines a KeyTable.
|
-l |
Log via calls to syslog(3) any interesting activity. |
-L min[%+]
Instructs the verification code to fail messages for which a partial signature was received. There are three possible formats: min indicating at least min bytes of the message must be signed (or if the message is smaller than min then all of it must be signed); min% requiring that at least min percent of the received message must be signed; and min+ meaning there may be no more than min bytes of unsigned data appended to the message for it to be considered valid.
|
-n |
Parse the configuration file and command line arguments, reporting any errors found, and then exit. The exit value will be 0 if the filter would start up without complaint, or non-zero otherwise. |
-o dataset
Specifies a list of headers that should be omitted when generating signatures. If an entry in the list names any header which is mandated by the DKIM specification, the entry is ignored. A set of headers is listed in the DKIM specification as "SHOULD NOT" be signed; the default list for this parameter contains those headers (Return-Path, Received, Comments, Keywords, Bcc, Resent-Bcc and DKIM-Signature). To omit no headers, simply use the string "-" (or any string that will match no headers).
-p socketspec
Specifies the socket that should be established by the filter to receive connections from sendmail(8) in order to provide service. socketspec is in one of two forms: local:path which creates a UNIX domain socket at the specified path, or inet:port[@host] or inet6:port[@host] which creates a TCP socket on the specified port using the requested protocol family. If the host is not given as either a hostname or an IP address, the socket will be listening on all interfaces. A literal IP address must be enclosed in square brackets. If neither socket type is specified, local is assumed, meaning the parameter is interpreted as a path at which the socket should be created. This parameter is mandatory either here or in the configuration file.
-P pidfile
Specifies a file into which the filter should write its process ID at startup.
|
-Q |
Query test mode. The filter will read two lines from standard input, one containing a database description to be opened and one containing a string of the form "q/n" where "q" is the query to be performed and "n" is the number of fields to be retrieved. | ||
|
-r |
Checks all messages for compliance with RFC5322 header count requirements. Non-compliant messages are rejected. |
-s selector
Defines the name of the selector to be used when signing messages. See the DKIM specification for details.
-S signalg
Selects the signing algorithm to use when generating signatures. Use ’opendkim -V’ to see the list of supported algorithms. Valid signing algorithms are rsa-sha256 and ed25519-sha256 (RFC 8463). Note that rsa-sha1 is retained for verification of existing signatures but is no longer accepted as a signing algorithm. The default is rsa-sha256.
-t testfiles
Evaluates (verifies) one or more RFC5322-formatted message found in testfiles and exits. The value of testfiles should be a comma-separated list of one or more filenames, one of which may be "-" if the message should be read from standard input.
-T secs
Sets the DNS timeout in seconds. A value of 0 causes an infinite wait. The default is 5. Ignored if not using an asynchronous resolver package. See also the NOTES section below.
-u userid[:group]
Attempts to be come the specified userid before starting operations. The process will be assigned all of the groups and primary group ID of the named userid unless an alternate group is specified. See the FILE PERMISSIONS section for more information.
|
-v |
Increase verbose output during test mode (see -t above). May be specified more than once to request increasing amounts of output. | ||
|
-V |
Print the version number and supported canonicalization and signature algorithms, and then exit without doing anything else. | ||
|
-W |
If logging is enabled (see -l above), issues very detailed logging about the logic behind the filter’s decision to either sign a message or verify it. The "W" stands for "Why?!" since the logic behind the decision is non-trivial and can be confusing to administrators not familiar with its operation. A description of how the decision is made can be found in the OPERATION section of this document. This causes a large increase in the amount of log data generated for each message, so it should be limited to debugging use and not enabled for general operation. |
-x configfile
Read the named configuration file. See the opendkim.conf(5) man page for details. Values in the configuration file are overridden when their equivalents are provided on the command line until a configuration reload occurs. The OPERATION section describes how reloads are triggered. The default is to read a configuration file from /etc/opendkim/opendkim.conf if one exists, or otherwise to apply defaults to all values.
|
-X |
Tolerates configuration file items that have been internally marked as "deprecated". Normally when a configuration file item is removed from the package, it is flagged in this way for at least one full release cycle. The presence of a deprecated configuration file item typically causes the filter to return an error and refuse to start. Setting this flag will allow the filter to start and a warning is logged. In some future release when the item is removed completely, a different error results, and it will not be possible to start the filter. Use of this flag is NOT RECOMMENDED; it could effectively hide a major configuration change with serious security implications. |
OPERATION
A message will be verified unless it conforms to the signing criteria, which are: (1) the domain on the From: address (if present) must be listed by the -d command line switch or the Domain configuration file setting, and (2) (a) the client connecting to the MTA must have authenticated, or (b) the client connecting to the MTA must be listed in the file referenced by the InternalHosts configuration file setting (or be in the default list for that option), or (c) the client must be connected to a daemon port named by the MTAs configuration file setting, or (d) the MTA must have set one or more macros matching the criteria set by the MacroList configuration file setting.
For (a) above, the test is whether or not the MTA macro "{auth_type}" is set and contains any non-empty value. This means the MTA must pass the value of that macro to the filter before or during the end-of-header (EOH) phase in order for its value to be tested. Check your MTA’s configuration documentation for details.
For (1) above, other header fields may be selected using the SenderHeaders configuration file setting. See opendkim.conf(5) for more information.
When signing a message, a DKIM-Signature: header will be prepended to the message. The signature is computed using the private key provided. You must be running a version of sendmail(8) recent enough to be able to do header prepend operations (8.13.0 or later).
When verifying a message, an Authentication-Results: header will be prepended to indicate the presence of a signature and whether or not it could be validated against the body of the message using the public key advertised by the sender’s nameserver. The value of this header can be used by mail user agents to sort or discard messages that were not signed or could not be verified.
Upon receiving SIGUSR1, if the filter was started with a configuration file, it will be re-read and the new values used. Note that any command line overrides provided at startup time will be lost when this is done. Also, the following configuration file values (and their corresponding command line items, if any) are not reloaded through this process: AutoRestart (-A), AutoRestartCount, AutoRestartRate, Background, MilterDebug, PidFile (-P), Quarantine (-q), Socket (-p), StrictTestMode, TestPublicKeys, UMask, UserID (-u). The filter does not automatically check the configuration file for changes and reload.
MTA MACROS
opendkim makes use of three MTA-provided macros, plus any demanded by configuration. The basic three are: "i" (the envelope ID, also known as the job ID or the queue ID), which is used for logging; "daemon_name" (the symbolic name given to the MTA instance that accepted the connection), which is used when performing tests against any "MTAs" setting used; and "auth_type", which is used to determine whether or not the SMTP client authenticated to the MTA. If the MTA does not provide them to opendkim then it is not able to apply their corresponding tests or do useful logging. Consult your MTA documentation to determine how to adjust your its configuration if some or all of these are not available.
FILE PERMISSIONS
When the filter is started as the superuser and the UserID (-u) setting is used, the filter gives up its root privileges by changing to the specified user after the following steps are taken: (1) the configuration file (if any) is loaded; (2) if the KeyFile (-k) setting is used, that key is loaded into memory; (3) all data sets in the configuration file are opened, and those that are based on flat files are also read into memory; and (4) if ChangeRootDirectory is set, the process root is changed to that directory. This means on configuration reload, the filter will not be accessing these files or the configuration file as the superuser (and possibly from a different root), and any key files referenced by the KeyTable will also be accessed by the new user.
Thus, keys referenced by the KeyTable must always be accessible for read by the unprivileged user. Also, run-time reloads are not possible if any of the other files will not be readable by the unprivileged user.
ENVIRONMENT
The following
environment variable(s) can be used to adjust the behaviour
of this filter:
DKIM_TMPDIR
The directory to use when creating temporary files. The default is /tmp.
NOTES
When using DNS timeouts (see the -T option above), be sure not to use a timeout that is larger than the timeout being used for interaction between sendmail and the filter. Otherwise, the MTA could abort a message while waiting for a reply from the filter, which in turn is still waiting for a DNS reply.
Features that involve specification of IPv4 addresses or CIDR blocks will use the inet_addr(3) function to parse that information. Users should be familiar with the way that function handles the non-trivial cases (for example, "192.0.2/24" and "192.0.2.0/24" are not the same thing).
EXIT STATUS
Filter exit status codes are selected according to sysexits(3).
HISTORY
DKIM is an amalgam of Yahoo!’s DomainKeys proposal, and Cisco’s Internet Identified Mail (IIM) proposal.
VERSION
This man page covers version 3.0.0 of opendkim.
COPYRIGHT
Copyright (c)
2007, 2008, Sendmail, Inc. and its suppliers.
Copyright (c) 2009-2015, The Trusted Domain Project.
Copyright (c) 2026, PhoenixDKIM contributors.
All rights reserved.
SEE ALSO
opendkim.conf(5), sendmail(8)
Sendmail Operations Guide
RFC5321 - Simple Mail Transfer Protocol
RFC5322 - Internet Messages
RFC5451 - Message Header Field for Indicating Message Authentication Status
RFC6008 - Authentication-Results Registration for Differentiating among Cryptographic Results
RFC6376 - DomainKeys Identified Mail
RFC8463 - A New Cryptographic Signature Method for DomainKeys Identified Mail (DKIM)
This document was created from the manual pages using groff.
Time: Mon Jun 1 17:05:59 2026