expand-alias - expand mail aliases from /etc/aliases
$ expand-alias MAILER-DAEMON root $ expand-alias -c listname addr1, addr2, addr3 $ expand-alias -n listname addr1 addr2 addr3 $ expand-alias -t listname addr1 addr2 addr3 $ expand-alias -f ~/my.aliases friends friend1@isp.net other.friend@isp2.net $ expand-alias -f ~/my.aliases -s friends friend1@isp.net and other.friend@isp2.net
expand-alias expands aliases from an aliases file, as implemented by the Mail::ExpandAliases module.
expand-alias
expand-alias takes 0 or more aliases as arguments:
$ expand-alias postmaster darren@cpan.org $ expand-alias foo foo
Note that unknown aliases expand to themselves; that is, they don't expand.
expand-alias has several command line swicthes that control the output:
comma-separated output:
$ expand-alias -c listname addr1, addr2, addr3
tab-separated output
$ expand-alias -c listname addr1 addr2 addr3
newline separated output
$ expand-alias -n listname addr1 addr2 addr3
"sentence" form (a, b, and c).
$ expand-alias -s listname addr1, addr2, and addr3
The default separator is a single space:
$ expand-alias listname addr1 addr2 addr3
This is useful in shell scripts:
$ for addr in `expand-alias -f ~/my.lists friends`; do > mail -s 'For your eyes only!' $addr < secret-file > done
expand-alias also takes a -f option, as hinted above, which indicates the file to be used; by default this is either /etc/aliases or /etc/mail/aliases, tried in order until one is found.
-f
If the -v (verbose) flag is set, alias expansions are prefixed by the alias itself. This is useful when specifying multiple aliases on the command line:
-v
$ expand-alias -vc listone listtwo listthree listone: addr1, addr2, addr3 listtwo: addr4, addr3, addr2 listthree: addr1, addr4, addr3
expand-alias works by reading the /etc/aliases file; it does not attempt a EXPN against an SMTP server, and, for security reasons, it does not try to read a user's .forward file.
darren chamberlain <darren@cpan.org>
Perl, Mail::ExpandAliases
To install Mail::ExpandAliases, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::ExpandAliases
CPAN shell
perl -MCPAN -e shell install Mail::ExpandAliases
For more information on module installation, please visit the detailed CPAN module installation guide.