Home General Topics Exim Utilities ..

Exim Utilities ..

by SupportPRO Admin

EXIM UTILITIES

Introduction

Exim is the default mail transport agent installed on some Linux systems; it runs on many versions of Unix and is suitable for any TCP/IP network with any combination of hosts and end-user mail software. It is open source, scalable, rich in features, andbest of all-easy to configure.

Exim utilities

  • exiwhat : List what Exim processes are doing.

The exiwhat script sends the signal to all Exim processes it can find, having first emptied the file. It then waits for one second to allow the Exim processes to react before displaying the results. In order to run exiwhat successfully you have to have sufficient privilege to send the signal to the Exim processes, so it is normally run as root.

  • exiqgrep : grep the queue

exim -bpu : to obtain a queue listing with-undelivered recipients only, and then greps the output to select messages that match given criteria. The following selection options are available:

-f <regex> Match the sender address. The field that is tested is enclosed in angle brackets, so you can test for bounce messages with

exiqgrep -f ^<>$

-r <regex>Match a recipient address. The field that is tested is not enclosed in angle brackets.

-s <regex> Match against the size field.

-y <seconds> Match messages that are younger than the given time.

-o <seconds> Match messages that are older than the given time.-z Match only frozen messages.

-x Match only non-frozen messages.

The following options control the format of the output:

-c Display only the count of matching messages.

-l Long format display the full message information as output by Exim. This is the default.

-i Display message ids only.

-b Brief format one line per message.

-R Display messages in reverse order.

There is one more option, -h, which outputs a list of options.

  • exiqsumm : summarize the queue

The exiqsumm utility is a Perl script which reads the output of exim -bp and produces a summary of the messages on the queue. Thus, you use it by running a command such as

exim -bp | exiqsumm

The output consists of one line for each domain that has messages waiting for it, as in the following example:

3 2322 74m 66m msn.com.example

  • exigrep : Extracting specific information from the log

The exigrep utility is a Perl script that searches one or more main log files for entries that match a given pattern. When it finds a match, it extracts all the log entries for the relevant message, not just those that match the pattern. Thus, exigrep can extract complete log entries for a given message, or all mail for a given user, or for a given host, for example. The input files can be in Exim log format or syslog format.

If a matching log line is not associated with a specific message, it is always included in exigreps output. The usage is:

exigrep [-l] [-t<n>] <pattern> [<log file>]

  • exipick: Selecting messages by various criteria

It lists messages from the queue according to a variety of criteria. For details, run:

exipick help

  • Exicyclog: Cycling log files

The exicyclog script can be used to cycle (rotate) mainlog and reject-log files. This is not necessary if only syslog is being used, or if you are using log files with date stamps in their names.Some operating systems have their own standard mechanisms for log cycling, and these can be used instead of exicyclog if preferred. There are two command line options for exicyclog:

1)-k <count> specifies the number of log files to keep, overriding the default that is set when Exim is built. The default default is 10.

2)-l <path> specifies the log file path, in the same format as Exims log_file_path option (for example, /var/log/exim_%slog), again overriding the scripts default, which is to find the setting from Exims configuration.

  • eximstats: (Mail statistics)?

A Perl script called eximstats is provided for extracting statistical information from log files. The output is either plain text, or HTML. By default, eximstats extracts information about the number and volume of messages received from or delivered to various hosts. The information is sorted both by message count and by volume, and the top fifty hosts in each category are listed on the standard output. Similar information, based on email addresses or domains instead of hosts can be requested by means of various options. For messages delivered and received locally, similar statistics are also produced per user.

  • exim_checkaccess (Checking access policy)?

The -bh command line argument allows you to run a fake SMTP session with debugging output, in order to check what Exim is doing when it is applying policy controls to incoming SMTP mail. However, not everybody is sufficiently familiar with the SMTP protocol to be able to make full use of -bh, and sometimes you just want to answer the question Does this address have access? without bothering with any further details.

The exim_checkaccess utility is a packaged version of -bh. It takes two arguments, an IP address and an email address:

exim_checkaccess 10.9.8.7

  • exim_dbmbuild : (Making DBM files)?

The exim_dbmbuild program reads an input file containing keys and data in the format used by the lsearch look-up (see section 9.3). It writes a DBM file using the lower-cased alias names as keys and the remainder of the information as data. The lower-casing can be prevented by calling the program with the -nolc option. A terminating zero is included as part of the key string. This is expected by the dbm look-up type. However, if the option -nozero is given, exim_dbmbuild creates files without terminating zeroes in either the key strings or the data strings. The dbmnz look-up type can be used with such files.

The program requires two arguments: the name of the input file (which can be a single hyphen to indicate the standard input), and the name of the output file. It creates the output under a temporary name, and then renames it if all went well. If the native DB interface is in use (USE_DB is set in a compile-time configuration file this is common in free versions of Unix) the two file names must be different, because in this mode the Berkeley DB functions create a single output file using exactly the name given. For example,

exim_dbmbuild /etc/aliases /etc/aliases.db

  • exinext : (Finding individual retry times)?

A utility called exinext provides the ability to fish specific information out of the retry database. Given a mail domain it looks up the hosts for that domain, and outputs any retry information for the hosts or for the domain. At present, the retry information is obtained by running exim_dumpdb (see below) and post-processing the output.

For example:

$ exinext

piglet@milne.fict.exampleThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it

support.supportpro.example:192.168.0.53 error 146: Connection refused

first failed: 21-Feb-1996 14:57:34

last tried: 21-Feb-1996 14:57:34

next try at: 21-Feb-1996 15:02:34

past final cutoff time

  • exim_dumpdb : (dump a hints database)?

Three utility programs are provided for maintaining the DBM files that Exim uses to contain its delivery hint information. Each program requires two arguments. The first specifies the name of Exims spool directory, and the second is the name of the database it is to operate on. These are as follows:

*retry: the database of retry information

*wait-<transport name>: databases of information about messages waiting for remote hosts

*callout: the callout cache

*ratelimit: the data for implementing the ratelimit ACL condition

*misc: other hints data

The misc database is used for :

* Serializing ETRN runs (when smtp_etrn_serialize is set)?

* Serializing delivery to a specific host (when serialize_hosts is set in an smtp transport)?

  • exim_tidydb : (clean up a hints database)?

The exim_tidydb utility program is used to tidy up the contents of a hints database. If run with no options, it removes all records that are more than 30 days old. The age is calculated from the date and time that the record was last updated. Note that, in the case of the retry database, it is not the time since the first delivery failure. Information about a host that has been down for more than 30 days will remain in the database, provided that the record is updated sufficiently often.

The cutoff date can be altered by means of the -t option, which must be followed by a time. For example, to remove all records older than a week from the retry database:

exim_tidydb -t 7d /var/spool/exim retry

Both the wait-xxx and retry databases contain items that involve message ids. In the former these appear as data in records keyed by host they were messages that were waiting for that host and in the latter they are the keys for retry information for messages that have suffered certain types of error. When exim_tidydb is run, a check is made to ensure that message ids in database records are those of messages that are still on the queue. Message ids for messages that no longer exist are removed from wait-xxx records, and if this leaves any records empty, they are deleted. For the retry database, records whose keys are non-existent message ids are removed. The exim_tidydb utility outputs comments on the standard output whenever it removes information from the database.

  • exim_fixdb : (patch a hints database)?

The exim_fixdb program is a utility for interactively modifying databases. Its main use is for testing Exim, but it might also be occasionally useful for getting round problems in a live system. It has no options, and its interface is somewhat crude. On entry, it prompts for input with a right angle-bracket. A key of a database record can then be entered, and the data for that record is displayed.

If d is typed at the next prompt, the entire record is deleted. For all except the retry database, that is the only operation that can be carried out. For the retry database, each field is output preceded by a number, and data for individual fields can be changed by typing the field number followed by new data,

for example:

> 4 951102:1000

resets the time of the next delivery attempt. Time values are given as a sequence of digit pairs for year, month, day, hour, and minute. Colons can be used as optional separators.

  • exim_lock : (Mailbox maintenance)?

The exim_lock utility locks a mailbox file using the same algorithm as Exim. For a discussion of locking issues, see section 26.3. Exim_lock can be used to prevent any modification of a mailbox by Exim or a user agent while investigating a problem. The utility requires the name of the file as its first argument. If the locking is successful, the second argument is run as a command (using Cs system() function); if there is no second argument, the value of the SHELL environment variable is used; if this is unset or empty, /bin/sh is run. When the command finishes, the mailbox is unlocked and the utility ends. The following options are available:

-fcntl : Use fcntl() locking on the open mailbox.

-flock : Use flock() locking on the open mailbox, provided the operating system supports it.

-interval : This must be followed by a number, which is a number of seconds; it sets the interval to sleep between retries (default 3).

-lock : fileCreate a lock file before opening the mailbox.

-mbx : Lock the mailbox using MBX rules.

-q : Suppress verification output.

-retries : This must be followed by a number; it sets the number of times to try to get the lock

-restore_time :This option causes exim_lock to restore the modified and read times to the locked file before exiting. This allows you to access a locked mailbox (for example, to take a backup copy) without disturbing the times that the user subsequently sees.

-timeout :This must be followed by a number, which is a number of seconds; it sets a timeout to be used with a blocking fcntl() lock. If it is not set (the default), a non-blocking call is used.

-v :Generate verbose output.

If none of -fcntl, -flock, -lockfile or -mbx are given, the default is to create a lock file and also to use fcntl() locking on the mailbox, which is the same as Exims default. The use of -flock or -fcntl requires that the file be writeable; the use of -lockfile requires that

the directory containing the file be writable. Locking by lock file does not last for ever; Exim assumes that a lock file is expired if it is more than 30 minutes old.

The -mbx option can be used with either or both of -fcntl or -flock. It assumes -fcntl by default. MBX locking causes a shared lock to be taken out on the open mailbox, and an exclusive lock on the file /tmp/.n.m where n and m are the device number and inode number of the mailbox file. When the locking is released, if an exclusive lock can be obtained for the mailbox, the file in /tmp is deleted.

The default output contains verification of the locking that takes place. The -v option causes some additional information to be given. The -q option suppresses all output except error messages.

A command such as

exim_lock /var/spool/mail/spqr

runs an interactive shell while the file is locked, whereas

exim_lock -q /var/spool/mail/spqr <<End

<some commands>

End

runs a specific non-interactive sequence of commands while the file is locked, suppressing all verification output. A single command can be run by a command such as

exim_lock -q /var/spool/mail/spqr \

cp /var/spool/mail/spqr /some/where

Note that if a command is supplied, it must be entirely contained within the second argument hence the quotes.

Article Authored by Sreejith KR

Author, Sreejith, is a Systems Engineer with SupportPRO. Sreejith specializes in Level 1 and Level 2 Linux / Windows Administration. SupportPRO offers 24X7 technical support services to Web hosting companies and service providers.

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment