FDM.CONF(5)
π NAME π
okay so this is fdm.conf(5) β the manual page for the fdm configuration file. That's it, that's the whole name section, but bestie you're gonna want to keep reading because this file is literally where all the magic happens β¨
πΈ DESCRIPTION πΈ
So here's the tea: this page describes the fdm(1) configuration file. That file is the blueprint for everything β it defines accounts you fetch mail from, a whole menu of actions you can take on that mail, and rules that glue a regexp to an action. it's giving "matchmaker for mail" fr fr π
The file gets parsed once, top to bottom. Which means: action and account definitions have to show up before any rule that references them. no showing up late to the function, bestie π«Ά
Rules get evaluated first to last, and β unless the continue keyword overrides it β evaluation stops at the first match. periodt.
The file format is:
- Empty lines? ignored. π
- Lines starting with the
#character? Also ignored. - Regexps and strings must be enclosed in double quotes
"". - Special characters in regexps and strings (yes, including passwords π) must be escaped.
- Heads up: that can mean you end up double-escaping inside regexps. it's giving stressful but we move π
Possible commands are covered in the following sections. let's gooo π
β¨ OPTIONS β¨
Options are configured using the set command. It may be followed by the following options, one per command:
maximum-sizesize β sets the max size of a mail. Mails bigger than this limit get dropped, and if applicable they are not deleted from the server. The size can be a plain number in bytes, or you can tack on a suffix:Kfor kilobytes,Mfor megabytes,Gfor gigabytes. Default is32megabytes, and the max is one gigabyte. πdelete-oversizedβ if you set this,fdm(1)tries to delete messages that exceedmaximum-sizeand then continue on its merry way. If you don't set it, oversize messages are a fatal error andfdm(1)will abort. π
ngl this one needs a moment of reflection:fdm(1)may have a bunch of messages queued (up to thequeue-highsetting, and that's doubled for rewrite, per account). So set this andqueue-highonly after you've thought about how much space is in your temporary folder β and about what happens iffdm(1)aborts because that space fills up. π«
queue-highnumber β this sets the max number of messagesfdm(1)will hold at once.fdm(1)will try to process previously queued messages while the next one is being fetched. Once you hit this limit, no further messages get fetched until the number of held messages drops down to thequeue-lowvalue.queue-lownumber β the length the message queue has to drop to before fetching resumes, after thequeue-highlimit has been reached.ignore-errorsβ if set,fdm.confkeeps processing mail even when a delivery fails, instead of aborting. resilience era πͺallow-multipleβ if specified,fdm(1)doesn't try to create a lock file, and allows multiple instances to run simultaneously. chaos permitted π¦lock-filepath β sets an alternative lock file. Default is~/.fdm.lockfor non-root users and/var/db/fdm.lockfor root.lock-timeouttime β how longfdm.confwill try for a lock file before giving up.lock-waitβ if present,fdm.confwill wait forlock-fileforlock-timeout, instead of exiting immediately with an error. patience is a virtue bestie π§command-useruser β specifies the user used to runexecandpipeactions. By default it's the user who invokedfdm.default-useruser β sets the default user to change to before delivering mail, iffdm(1)is running as root and no alternative user was specified as part of the action or rule. This can be overridden with the-uswitch on the command line. A default user must be given if you're running as root. no skipping this one π¨lookup-orderlocation ... β specifies the order to do user lookup in, left to right. Possible types arepasswd(use thepasswd(5)file) orcourier(use Courier authlib, if support is compiled).lock-typestype ... β specifies the locks used formboxlocking. Possible types arefcntl,flock, anddotlock.flockandfcntlare mutually exclusive. Default isflock. pick a lane πproxyurl β tellsfdm(1)to proxy all connections through url. HTTP and SOCKS5 proxies are supported at present (URLs of the formhttp://host[:port]orsocks://[user:pass@]host[:port]). No authentication is supported for HTTP.unmatched-maildrop|keepβ controls whatfdm(1)does with mail that reaches the end of the ruleset (i.e. mail matching no rules, or matching only rules with thecontinuekeyword).dropdiscards such mail;keepattempts to leave the mail on the server. The default is to keep the mail and log a warning that it reached the end of the ruleset.purge-aftercount β makesfdm(1)attempt to purge deleted mail from the server (if supported) after count mails have been retrieved. Useful on unreliable connections to limit the potential number of mails refetched if the connection drops β but note it can incur a considerable speed penalty. β οΈno-receivedβ if present,fdm(1)will not insert aReceivedheader into each mail.no-createβ if set,fdm(1)will not attempt to create maildirs and mboxes, or missing elements of their paths.file-umaskuser | umask β specifies theumask(2)to use when creating files.usermeans use the umask set whenfdm(1)was started, or you can specify umask as a three-digit octal number. Default is077.file-groupuser | group β lets you set the default group ownership of files and directories created byfdm(1). group can be a group name string or a numeric gid. Ifuseris used, or this option doesn't appear in the config file,fdm(1)doesn't attempt to set the group of new files and directories.timeouttime β controls the max time to wait for a server to send data before closing a connection. Default is900seconds.verify-certificatesβ tellsfdm(1)to verify SSL certificates for all SSL connections. π
π INCLUDING FILES π
You can pull in more config files with the include command:
include path
The file to include gets searched for first as an absolute path, and then relative to the directory containing the main configuration file. π
π¦ MACROS π¦
Macros are your bestie for not repeating yourself. Define them like this:
$name = string
%name = number
Macros are prefixed with $ to mean a string value, and % to mean a numeric value. Once defined, a macro can be used any place a string or number is expected. You can also embed macros inside strings by wrapping their name (after the $ or %) in {}s, like so:
"abc ${mymacro} %{anothermacro} def"
The ifdef, ifndef and endif keywords may be used to conditionally parse a section of the configuration file, depending on whether the given macro exists or doesn't exist. ifdef and ifndef blocks may be nested. πͺ
π SHELL COMMANDS π
The result of a shell command can be used at any point a string or number is expected, by wrapping it in $() or %(). Use $() and the command result is used as a string; use %() and it gets converted to an integer. Shell commands are executed when the configuration file is parsed. π
π ACCOUNTS π
okay so bestie, the account command is literally how you tell fdm(1) where to go scoop up your mail from. the syntax is giving:
account name [users] [disabled] type [args] [keep]
the name argument is a string, and it's just a name for the account, okay? and then there's this optional users argument that looks like:
user user | users { user ... }
those first two options say which user (or list of users) the mail should be delivered as when an action runs. if you don't say anything about users, the default user gets used β that's the one you set with set default-user. and listen: users you set inside the account definition can get overridden by similar arguments in action definitions or on match rules, so watch out π. also if fdm(1) is running as non-root, it'll still execute any actions once for each user, but it cannot change to that user, so the action ends up running multiple times as the current user. noted π
the disabled keyword tells fdm(1) to straight-up ignore this account unless you explicitly enable it with a -a option on the command line. and if you use keep, all mail collected from this account is kept (not deleted) even if it matches a drop action. slay.
supported account types and their args are:
π stdin
this one reads mail from stdin, if stdin is connected to a pipe. you'd use it to deliver mail from sendmail(8) β see fdm(1) for the deets.
π pop3 server / pop3s server
pop3 server host [port port] [user user] [pass pass] [only] [no-apop]
[no-uidl] [starttls] [insecure]
pop3s server host [port port] [userpass] [only] [no-apop] [no-verify]
[no-uidl] [insecure]
these define a POP3 or POP3S account. the userpass element is shaped like:
[user user] [pass pass]
host, user and pass all have to be strings. if you don't hand over the user or the pass, fdm(1) goes looking for it in the ~/.netrc file (see ftp(1) for what that file format even is). the port option can be either a string β which gets looked up in the services(5) database β or a number. leave it out and you get the default port: 110 for POP3, 995 for POP3S.
the only option takes this form:
[new-only | old-only] cache path
new-only fetches only mail that hasn't been fetched before, and old-only is the opposite vibe: it fetches only mail that has been fetched before. the cache file saves the state of the POP3 mailbox. the no-apop flag forces fdm(1) to not use the POP3 APOP command for authentication, and no-verify tells fdm(1) to skip SSL certificate validation for this account (yes, for real π). no-uidl makes fdm(1) not use the UIDL command to retrieve mails β mainly useful for broken POP3 servers. starttls attempts to use STARTTLS after connection. and insecure allows the use of insecure protocols, which currently includes SSLv2, SSLv3 and TLS1.0. β οΈ
π¦ pop3 pipe
pop3 pipe command [userpass] [only] [no-apop]
this account type runs the POP3 protocol piped through command, like ssh(1). if the command produces any output to stderr, it gets logged. for POP3 over a pipe, providing a user and password is not optional, and it may not be read from ~/.netrc. no shortcuts bestie.
πΈ imap server / imaps server
imap server host [port port] [userpass] [folder name] [only]
[no-cram-md5] [no-plain] [no-login] [starttls] [insecure]
[oauthbearer] [xoauth2]
imap server host [port port] [userpass] [folders] { name ... } [only]
imaps server host [port port] [userpass] [folders] [only] [no-verify]
[no-cram-md5] [no-plain] [no-login] [insecure] [oauthbearer]
[xoauth2]
these define an IMAP or IMAPS account. the parameters work like a POP3 or POP3S account, except there's this extra folders option that sets the name of the folder (or folders) to use β default is to fetch from the inbox. it looks like:
folder name | folders { name ... }
default ports are 143 for IMAP and 993 for IMAPS. for IMAP, the only item is just one of the keywords new-only or old-only β no cache file needed, periodt.
the options no-cram-md5, no-plain and no-login disable the given authentication method. default is: use CRAM-MD5 if it's available, then PLAIN, and LOGIN otherwise.
starttls attempts to use STARTTLS after connection.
insecure allows the use of insecure protocols, which currently includes SSLv2, SSLv3 and TLS1.0. again, be careful π
oauthbearer attempts to use an OAuth 2.0 bearer token as the authentication method.
π§ imap pipe
imap pipe command [userpass] [folders] [only]
same energy as pop3 pipe: this account type runs the IMAP protocol piped through command. if you supply the optional IMAP user and pass, they'll be used if necessary β but if one is provided, both must be, and using ~/.netrc is not permitted.
mail fetched using the IMAP protocol is tagged with a folder tag containing the source folder name. cute.
π maildir / maildirs
maildir path
maildirs { path ... }
these account types tell fdm(1) to fetch mail from the maildir or maildirs you specified. this is how you get fdm(1) to filter mail β fetching from a maildir and deleting (dropping) unwanted mail, or delivering mail to another maildir or to an mbox.
mail fetched from a maildir gets tagged with a maildir tag containing the basename of the mail file.
π mbox / mboxes
mbox path
mboxes { path ... }
basically the same as maildir and maildirs, but they make fdm(1) fetch mail from an mbox or a whole set of mboxes instead.
mail fetched from a mbox gets tagged with a mbox tag containing the basename of the mbox file.
β nntp / nntps
nntp server host [port port] [userpass] group group cache cache
nntp server host [port port] [userpass] groups { group ... } cache cache
nntps server host [port port] [userpass] group group cache cache
nntps server host [port port] [userpass] groups { group ... } cache
cache
an NNTP account. articles get fetched from the group (or groups) you name and then delivered. the index and message-id of the last article fetched in each group is saved in the specified cache file. when fdm(1) runs again, fetching begins at the cached article. and note: the keep option is completely ignored for NNTP accounts β all mail is kept, and the cache is always updated. like, don't even bother.
β¨ TAGGING β¨
as mail gets processed by fdm(1), it's tagged with a bunch of name/value pairs. some tags get added automatically, and you can also tag mail explicitly using the tag action. tags can be inserted in most strings kind of like macros β except tags are processed at runtime, not while the configuration file is being parsed. big difference bestie.
a tag's value gets inserted by wrapping its name in %[], like:
abc%[account]def
%[hour]:%[minute]:%[second]
the default tags also have a single-letter shorthand. and including a tag that doesn't exist is the same as including a tag with an empty value, so "abc%[nonexistent]def" becomes "abcdef". the void, basically.
the automatically added tags are:
account(%a) β the name of the account from which the mail was fetched.home(%h) β the delivery user's home directory.uid(%n) β the delivery user's uid.action(%t) β the name of the last action executed for this mail.user(%u) β the delivery user's username.hour(%H) β the current hour (00β23).minute(%M) β the current minute (00β59).second(%S) β the current second (00β59).day(%d) β the current day of the month (01β31).month(%m) β the current month (01β12).year(%y) β the current year.year2β the current year as two digits.dayofweek(%W) β the current day of the week (0β6, Sunday is 0).dayofyear(%Y) β the current day of the year (001β366).quarter(%Q) β the current quarter (1β4).rfc822dateβ the current date in RFC822 format.mail_hourβ the hour from the mail's date header, if it exists and is valid, otherwise the current time.mail_minuteβ the minute from the mail's date header.mail_secondβ the second from the mail's date header.mail_dayβ the day from the mail's date header.mail_monthβ the month from the mail's date header.mail_yearβ the year from the mail's date header.mail_year2β the same as two digits.mail_dayofweekβ the day of the week from the mail's date header.mail_dayofyearβ the day of the year from the mail's date header.mail_quarterβ the quarter (1β4) from the mail's date header.mail_rfc822dateβ the mail's date in RFC822 format.linesβ the total number of lines in the message.body_linesβ the number of lines in the body.header_linesβ the number of lines in the header.message_idβ the message id from the mail's header (if present).hostnameβ the local hostname.
on top of all that, the shorthand %% gets replaced with a literal %, and %0 to %9 get replaced with the result of any bracket expressions in the last regexp. iykyk π
π CACHES π
fdm(1) can maintain a cache file holding a set of user-defined strings. but lowkey important: to use caches, fdm(1) must have been compiled with them enabled. caches are declared with the cache keyword:
cache path [expire age]
path is the location of the cache file. if you use the expire keyword, items in the cache get removed once they reach the age you specified. age can be given unadorned in seconds, or followed by one of these modifiers: seconds, hours, minutes, days, months or years.
caches must be declared before they're used. items get added to caches using the add-to-cache action, removed using the remove-from-cache action, and searched for using the in-cache condition β see below for the info on those. π«Ά
π¬ ACTIONS π¬
okay bestie, this is the part where we tell fdm what to actually do with the mail once it's been matched. iconic behavior. the action command defines an action, and then you can call it by name in rules (scroll down for rules, they're right there) to do a thing to a mail. the syntax is:
action name [users] action
action name [users] { action ... }
so name is just a string β that's the label for your action. the users argument works exactly the same way it does in an account definition. and lowkey important: an action's user setting may be overridden in the matching rule. so the rule can boss the action around. π
here are all the possible values for action. if you specify multiple actions, they get executed once, in the order specified, for each user. no cap.
dropβ Discard the mail. bye bye ποΈkeepβ Keep the mail, do not remove it from the account.tag string [value value]β This tags mail withstring, and optionallyvalue, which may be matched using thetaggedorstringconditions.maildir pathβ Save the mail to the maildir specified bypath. If the maildir or any part of its path does not exist, it is created, unless theno-createoption is set. Mail delivered to a maildir is tagged with amail_filetag containing the full path of the mail file. so organized β¨mbox path [compress]β Append the mail to the mbox atpath. Ifcompressis specified,fdm(1)will add.gztopathand attempt to write mail usinggzip(1)compression. If the mbox or any part of its path does not exist, it is created, unless theno-createoption is set. Mail delivered to an mbox is tagged with ambox_filetag containing the path of the mbox.exec commandβ Executecommand.pipe commandβ Pipe the mail tocommand.execandpipecommands are run as the command user.write pathβ Write the mail topath.append pathβ Append the mail topath.smtp server host [port port] [from from] [to to]β Connect to an SMTP server and attempt to deliver the mail to it. Iffromortois specified, they are passed to the server in theMAIL FROMorRCPT TOcommands. If not, the current user and host names are used.lmtp server path | host [port port] [from from] [to to]β Connect to an LMTP server and attempt to store the mail there. If a UNIX socket is to be used,pathmust be the absolute pathname.portdefaults to24. Iffromortois specified, they are passed to the server in theMAIL FROMorRCPT TOcommands. If not, the current user and host names are used.rewrite commandβ Pipe the entire mail throughcommandto generate a new mail and use that mail for any following actions or rules. glow-up for your email fr. an example of therewriteaction is:
action "cat" pipe "cat"
action "rewrite" rewrite "sed 's/bob/fred/g'"
# this rule will rewrite the message
match all action "rewrite" continue
# this rule will cat the rewritten message
match all action "cat"
add-header name value valueβ Add a headernamewith contentsvalue.remove-header nameremove-headers { name ... }β Remove all occurrences of headers matching thefnmatch(3)patternname.stdoutβ Write the mail to stdout. main character energy, just saying it out loud.add-to-cache path key keyβ This action adds the stringkeyto the cache specified bypath. Ifkeyalready exists in the cache, it is replaced.remove-from-cache path key keyβ Remove the stringkeyfrom the cachepath, if a matching key is present.action nameβ This invokes another named action. A maximum of five actions may be called in a sequence. five. that's the limit bestie, don't get greedy π
π RULES π
rules are specified using the match keyword. basic form goes like this:
match condition [and | or condition ...] [users] actions [continue]
the condition argument may be one of:
allβ Matches all mail. literally everything, no filtering, we love a broad audience.matchedβ Matches only mail that has matched a previous rule and been passed on withcontinue.unmatchedβ The opposite ofmatched: matches only mails which have matched no previous rules.account name | accounts { name ... }β Matches only mail fetched from the named account or accounts. The account names may include shell glob wildcards to match multiple accounts, as with the-aand-xcommand line options.tagged stringβ Matches mails tagged withstring.[case] regexp [in headers | in body]β Specifies aregexpagainst which each mail should be matched. The regexp matches may be restricted to either the headers or body of the message by specifying eitherin headersorin body. Thecasekeyword forces the regexp to be matched case-sensitively: the default is case-insensitive matching. the way the default is lowercase-c-chill... π§exec command [user user] returns (return code, stdout regexp)pipe command [user user] returns (return code, [case] stdout regexp)β These two conditions execute a command and test its return value and output. Thereturn codeargument is the numeric return code expected andstdout regexpis a regexp to be tested against the output of the command to stdout. Either of these two arguments may be omitted: if both are specified, both must match for the condition to be true. Thepipeversion will pipe the mail to the command's stdin when executing it. If auseris specified,fdm(1)will change to that user before executing the command, otherwise the current user (or root if started as root) is used.size < numbersize > numberβ Compare the mail size withnumber.string string to [case] regexpβ Matchstringagainstregexp.age < timeage > timeβ Theagecondition examines the mail's date header to determine its age, and matches if the mail is older (>) or newer (<) than thetimespecified. Thetimemay be given as a simple number in seconds, or followed by the wordseconds,hours,minutes,days,monthsoryearsto specify a time in different units.in-cache path key keyβ This condition evaluates to true if the stringkeyis in the cache atpath.attachment count < numberattachment count > numberattachment count == numberattachment count != numberβ These conditions match if the mail possesses a number of attachments less than, greater than, equal to or not equal tonumber.attachment total-size < sizeattachment total-size > sizeβ Matches if the total size of all attachments is smaller or larger thansize.attachment any-size < sizeattachment any-size > sizeβ Compare each individual attachment on a mail tosizeand match if any of them are smaller or larger.attachment any-type stringattachment any-name stringβ Match true if any of a mail's attachments possesses a MIME type or filename that matchesstring.fnmatch(3)wildcards may be used.
multiple conditions may be chained together using the and or or keywords. the conditions are tested from left to right. and any condition may be prefixed by the not keyword to invert it. (yes, not is giving iconic chaotic energy and i'm obsessed π)
the optional users argument to the first form has the same syntax as for an action definition. a rule's user list overrides any users given as part of the actions.
the actions list specifies the actions to perform when the rule matches a mail. it's either of a similar form:
action name | actions { name ... }
or you can specify a number of actions inline (lambda actions, so fancy β¨):
action action
action { action ... }
in the latter case, action follows the same form as described in the ACTIONS section. the actions are performed from first to last in the order they are specified in the rule definition.
if the continue keyword is present, evaluation will not stop if this rule is matched. instead, fdm(1) will continue to match further rules after performing any actions for this rule. it's like saying "okay and ALSOβ" π
πͺ NESTED RULES πͺ
rules may be nested by specifying further rules in braces:
match condition [and | or condition ...] {
match ...
}
the inner rules will not be evaluated unless the outer one matches. rules may be multiply nested β it's giving matryoshka, it's giving structure, we love to see it π. note that the outer rule does not count as a match for the purposes of the matched and unmatched conditions.
π FILES π
~/.fdm.confβ defaultfdm.confconfiguration file/etc/fdm.confβ default system-wide configuration file~/.fdm.lockβ default lock file/var/db/fdm.lockβ lock file for root user
π SEE ALSO π
π AUTHORS π
Nicholas Marriott <nicholas.marriott@gmail.com>
and that's a wrap bestie!! this page is from the Debian fam, dated August 21, 2006, and it lives at FDM.CONF(5). go forth and filter your mail like the main character you are πβ¨π¦πΈπ
π«Ά
π¦ where this page comes from
- alpine 3.24: fdm-doc 2.2-r2 Β· ISC
- arch rolling: fdm 2.2-3 Β· BSD
- nixos 26.05: fdm 2.2
- nixpkgs unstable: fdm 2.2
- ubuntu resolute: fdm 2.2+git20250202-3 Β· ISC
- ubuntu stonking: fdm 2.2+git20250202-3build1 Β· ISC
- Copyright (c) 2006 Nicholas Marriott <nicholas.marriott@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms