FDM.CONF(5) | File Formats Manual | FDM.CONF(5) |
fdm.conf
— fdm
configuration file
This manual page describes the fdm(1)
configuration file. It defines accounts from which to
fetch mail, a number of possible actions to take, and
rules
connecting a regexp with an action. The file is parsed once from top to
bottom, so action and account definitions must appear before they are
referenced in a rule. Rules are evaluated from first to last and (unless
overridden by the continue
keyword) evaluation stops
at the first match.
The file has the following format:
Empty lines and lines beginning with the ‘#’ character are ignored.
Regexps and strings must be enclosed in double quotes. Special characters in regexps and strings (including passwords) must be escaped. Note that this may mean double-escaping in regexps.
Possible commands are covered in the following sections.
Options are configured using the set
command. It may be followed by the following options, one per command:
maximum-size
sizeThe size may be specified as a plain number in bytes or with a
suffix of ‘K
’ for kilobytes,
‘M
’ for megabytes or
‘G
’ for gigabytes. The default is
32 megabytes and the maximum is one gigabyte.
delete-oversized
maximum-size
, and continue.
If it is not specified, oversize messages are a fatal error and cause
fdm(1) to abort.
Note that fdm(1) may have a number of
messages queued (up to the queue-high
setting,
doubled for rewrite, per account), so this setting and the
queue-high
option should be set after
consideration of the space available in the temporary folder and the
implications should fdm(1) abort due to the space
becoming full.
queue-high
numberqueue-low
value.queue-low
numberqueue-high
limit has been
reached.ignore-errors
fdm.conf
will continue to process mail if
a delivery fails rather than aborting.allow-multiple
lock-file
pathlock-timeout
timefdm.conf
will try a lock file before
giving up.lock-wait
fdm.conf
will wait for
lock-file
for lock-timeout
rather than exiting immediately with an error.command-user
userexec
and
pipe
actions. By default it is the user who
invoked fdm.default-user
user-u
switch on the command line. A default
user must be given if running as root.lookup-order
location ...passwd
to use the
passwd(5) file, or courier
to
use Courier authlib (if support is compiled).lock-types
type ...fcntl
, flock
, and
dotlock
. The flock
and
fcntl
types are mutually exclusive. The default is
flock
.proxy
urlunmatched-mail
drop
|
keep
continue
keyword).
drop
will cause such mail to be discarded, and
keep
will attempt 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-after
countpurge-after
option makes
fdm(1) attempt to purge deleted mail from the server (if
supported) after count mails have been retrieved.
This is useful on unreliable connections to limit the potential number of
mails refetched if the connection drops, but note that it can incur a
considerable speed penalty.no-received
no-create
file-umask
user
| umaskuser
means to use the umask set when
fdm(1) is started, or umask may be
specified as a three-digit octal number. The default is 077.file-group
user
| groupuser
is used, or this option does not appear in
the configuration file, fdm(1) does not attempt to set
the group of new files and directories.timeout
timeverify-certificates
Further configuration files may be including using the
include
command:
include
pathThe file to include is searched for first as an absolute path and then relative to the directory containing the main configuration file.
Macros may be defined using the following syntax:
Macros are prefixed with $ to indicate a string value and % to indicate a numeric value. Once defined, a macro may be used in any place a string or number is expected. Macros may be embedded in strings by surrounding their name (after the $ or %) with {}s, like so:
The ifdef
, ifndef
and endif
keywords may be used to conditionally
parse a section of the configuration file depending on whether or not the
macro given exists or does not exist. ifdef
and
ifndef
blocks may be nested.
The result of a shell command may be used at any point a string or number is expected by wrapping it in $() or %(). If the former is used, the command result is used as a string; if the latter, it is converted to an integer. Shell commands are executed when the configuration file is parsed.
The account
command is used to instruct
fdm(1) to fetch mail from an account. The syntax is:
account
name [users]
[disabled
] type
[args] [keep
]The name argument is a string specifying a name for the account. The optional users argument has the following form:
The first two options specify a user or list of users as which the
mail should be delivered when an action is executed. If no users are
specified, the default user (set with set
default-user
) is used. Users specified as part of
the account definition may be overridden by similar arguments to action
definitions or on match rules. If fdm(1) is run as
non-root, it will still execute any actions once for each user, but will be
unable to change to that user so the action will be executed multiple times
as the current user.
The disabled
keyword instructs
fdm(1) to ignore this account unless it is explicitly
enabled with a -a
option on the command line. If the
keep
keyword is specified, all mail collected from
this account is kept (not deleted) even if it matches a
drop
action.
Supported account types and arguments are:
stdin
stdin
, if it is
connected to a pipe. This may be used to deliver mail from
sendmail(8), see fdm(1) for
details.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
]user
user]
[pass
pass]The host, user and pass arguments must be strings. If the user or pass is not provided, fdm(1) attempts to look it up in the ~/.netrc file (see ftp(1) for details of the file format). The port option may be either a string which will be looked up in the services(5) database, or a number. If it is omitted, the default port (110 for POP3, 995 for POP3S) is used.
The only option takes the form:
new-only
| old-only
]
cache
pathnew-only
fetches only mail not
previously fetched, and old-only
is the inverse:
it fetches only mail that has been fetched before. The cache file is
used to save the state of the POP3 mailbox. The
no-apop
flag forces fdm(1) not
to use the POP3 APOP command for authentication, and the
no-verify
keyword instructs
fdm(1) to skip SSL certificate validation for this
account. The no-uidl
keyword makes
fdm(1) not use the UIDL command to retrieve mails.
This is mainly useful for broken POP3 servers.
starttls
attempts to use
STARTTLS after connection.
insecure
allows the use of insecure
protocols, which currently includes SSLv2, SSLv3 and TLS1.0.
pop3
pipe
command
[userpass] [only]
[no-apop
]stderr
, it is
logged. For POP3 over a pipe, providing a user and password is not
optional and it may not be read from
~/.netrc.imap
server
host
[port
port]
[userpass] [folder
name] [only]
[no-cram-md5
] [no-login
]
[starttls
] [insecure
]imap
server
host
[port
port]
[userpass] [folders
]
{
name ...
}
[only]imaps
server
host
[port
port]
[userpass] [folders]
[only] [no-verify
]
[no-cram-md5
] [no-login
]
[insecure
]The default ports used are 143 for IMAP and 993 for IMAPS. For
IMAP, the only item consists only of one of the
keywords new-only
or
old-only
- a cache file is not required.
Options no-cram-md5
and
no-login
disable the given authentication
method. The default is to use CRAM-MD5 if it is available, or LOGIN
otherwise.
starttls
attempts to use
STARTTLS after connection.
insecure
allows the use of insecure
protocols, which currently includes SSLv2, SSLv3 and TLS1.0.
imap
pipe
command
[userpass] [folders]
[only]pop3
pipe
, this
account type uses the IMAP protocol piped through
command. If the optional IMAP
user and pass are supplied,
they will be used if necessary, but if one is provided, both must be
– using ~/.netrc is not permitted.
Mail fetched using the IMAP protocol is tagged with a folder tag containing the source folder name.
maildir
pathmaildirs
{
path ...
}
Mail fetched from a maildir is tagged with a maildir tag containing the basename of the mail file.
mbox
pathmboxes
{
path ...
}
maildir
and
maildirs
, but cause fdm(1) to
fetch mail from an mbox or set of mboxes.
Mail fetched from a mbox is tagged with a mbox tag containing the basename of the mbox file.
nntp
server
host
[port
port]
[userpass] group
group cache
cachenntp
server
host
[port
port]
[userpass] groups
{
group ...
}
cache
cachenntps
server
host
[port
port]
[userpass] group
group cache
cachenntps
server
host
[port
port]
[userpass] groups
{
group ...
}
cache
cachekeep
option is completely
ignored for NNTP accounts – all mail is kept, and the cache is
always updated.As mail is processed by fdm(1), it is tagged
with a number of name/value pairs. Some tags are added automatically, and
mail may also be tagged explicitly by the user using the
tag
action. Tags may be inserted in most strings in
a similar manner to macros, except tags are processed at runtime rather than
as the configuration file is parsed. A tag's value is inserted by wrapping
its name in %[], for example:
The default tags also have a single-letter shorthand. Including a nonexistent tag in a string is equivalent to including a tag with an empty value, so "abc%[nonexistent]def" will be translated to "abcdef".
The automatically added tags are:
In addition, the shorthand %% is replaced with a literal %, and %0 to %9 are replaced with the result of any bracket expressions in the last regexp.
fdm(1) can maintain a cache file with a set of
user-defined strings. In order to use caches, fdm(1) must
have been compiled with them enabled. Caches are declared with the
cache
keyword:
cache
path [expire
age]The path is the location of the cache file.
If the expire
keyword is specified, items in the
cache are removed after they reach the age specified.
age may be given unadorned in seconds, or followed by
one of the modifiers: seconds, hours,
minutes, days, months
or years.
Caches must be declared before they are used. Items are 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 information on
these.
The action
command is used to define
actions. These may be specified by name in rules (see below) to perform some
action on a mail. The syntax is:
The name is a string defining a name for the action. The users argument has the same form as for an account definition. An action's user setting may be overridden in the matching rule.
The possible values for action are listed below. If multiple actions are specified they are executed once in the order specified, for each user.
drop
keep
tag
string [value
value]tagged
or string
conditions.maildir
pathno-create
option is set.
Mail delivered to a maildir is tagged with a mail_file tag containing the full path of the mail file.
mbox
path [compress
]compress
is specified, fdm(1)
will add ‘.gz’ to path and attempt to
write mail using gzip(1) compression. If the mbox or any
part of its path does not exist, it is created, unless the
no-create
option is set.
Mail delivered to an mbox is tagged with a mbox_file tag containing the path of the mbox.
exec
commandpipe
commandexec
and pipe
commands are
run as the command user.write
pathappend
pathsmtp
server
host
[port
port]
[from
from]
[to
to]rewrite
commandrewrite
action 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
valueremove-header
nameremove-headers
{
name ...
}
stdout
stdout
.add-to-cache
path key
keyremove-from-cache
path key
keyaction
nameRules are specified using the match
keyword. It has the following basic form:
match
condition [and
|
or
condition ...]
[users] actions
[continue
]The condition argument may be one of:
all
matched
continue
.unmatched
matched
: matches only mails which
have matched no previous rules.account
name |
accounts
{
name ...
}
-a
and -x
command line
options.tagged
stringcase
] regexp
[in
headers
|
in body
]in headers
or
in body
. The case
keyword
forces the regexp to be matched case-sensitively: the default is
case-insensitive matching.exec
command [user
user] returns
(return code, stdout
regexp)pipe
command [user
user] returns
(return code, [case
]
stdout regexp)stdout
. Either of these two arguments may be
omitted: if both are specified, both must match for the condition to be
true. The pipe
version will pipe the mail to the
command's stdin
when executing it. If a user is
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
>
numberstring
string to
[case
] regexpage
<
timeage
>
timeage
condition examines the mail's date header
to determine its age, and matches if the mail is older (>) or newer
(<) than the time specified. The time may be given as a simple number
in seconds, or followed by the word seconds,
hours, minutes,
days, months or
years to specify a time in different units.in-cache
path key
keyattachment
count
<
numberattachment
count
>
numberattachment
count
==
numberattachment
count
!=
numberattachment
total-size
<
sizeattachment
total-size
>
sizeattachment
any-size
<
sizeattachment
any-size
>
sizeattachment
any-type
stringattachment
any-name
stringMultiple conditions may be chained together using the
and
or or
keywords. The
conditions are tested from left to right. Any condition may be prefixed by
the not
keyword to invert it.
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 is either of a similar form:
Or may specify a number of actions inline (lambda actions):
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.
Rules may be nested by specifying further rules in braces:
The inner rules will not be evaluated unless the outer one
matches. Rules may be multiply nested. Note that the outer rule does not
count as a match for the purposes of the matched
and
unmatched
conditions.
fdm.conf
configuration fileNicholas Marriott <nicholas.marriott@gmail.com>
August 21, 2006 | Debian |