expn - recursively expand mail aliases
will use the SMTP expn
commands to expand
mail aliases. It will first look up the addresses you provide on the command
line. If those expand into addresses on other systems, it will connect to the
other systems and expand again. It will keep doing this until no further
expansion is possible.
The default output of expn
can contain many lines which are not valid
email addresses. With the -aa
flag, only expansions that result in
legal addresses are used. Since many mailing lists have an illegal address or
two, the single -a
, address, flag specifies that a few illegal
addresses can be mixed into the results. More -a
flags vary the ratio.
Read the source to track down the formula. With the -a
should be able to construct a new mailing list out of an existing one.
If you wish to limit the number of levels deep that expn
will recurse as
it traces addresses, use the -1
option. For each -1
level will be traversed. So, -111
will traverse no more than three
The normal mode of operation for expn
is to do all of its work silently.
The following options make it more verbose. It is not necessary to make it
verbose to see what it is doing because as it works, it changes its
 variable to reflect its current activity. To see how it is
expanding things, the -v
, verbose, flag will cause expn
each address before and after translation as it works. The -w
flag will cause expn
to show you its conversations with the mail
daemons. Finally, the -d
, debug, flag will expose many of the inner
workings so that it is possible to eliminate bugs.
No environment variables are used.
/tmp/expn$$ temporary file used as input to nslookup
(8), RFC 823, and RFC
Not all mail daemons will implement expn
. It is not
possible to verify addresses that are served by such daemons.
When attempting to connect to a system to verify an address, expn
tries one IP address. Most mail daemons will try harder.
It is assumed that you are running domain names and that the nslookup
program is available. If not, expn
will not be able to verify many
addresses. It will also pause for a long time unless you change the code where
it says $have_nslookup = 1
to read $have_nslookup = 0
does not handle every valid address. If you have an example,
please submit a bug report.
In 1986 or so, Jon Broome wrote a program of the same name that did about the
same thing. It has since suffered bit rot and Jon Broome has dropped off the
face of the earth! (Jon, if you are out there, drop me a line)
The latest version of expn
is available through anonymous ftp at