[24013] | 1 | NAME |
---|
| 2 | Mail::ExpandAliases - Expand aliases from /etc/aliases files |
---|
| 3 | |
---|
| 4 | SYNOPSIS |
---|
| 5 | use Mail::ExpandAliases; |
---|
| 6 | |
---|
| 7 | my $ma = Mail::ExpandAliases->new("/etc/aliases"); |
---|
| 8 | my @list = $ma->expand("listname"); |
---|
| 9 | |
---|
| 10 | DESCRIPTION |
---|
| 11 | I've looked for software to expand aliases from an alias file for a |
---|
| 12 | while, but have never found anything adequate. In this day and age, few |
---|
| 13 | public SMTP servers support EXPN, which makes alias expansion |
---|
| 14 | problematic. This module, and the accompanying "expand-alias" script, |
---|
| 15 | attempts to address that deficiency. |
---|
| 16 | |
---|
| 17 | USAGE |
---|
| 18 | Mail::ExpandAliases is an object oriented module, with a constructor |
---|
| 19 | named "new": |
---|
| 20 | |
---|
| 21 | my $ma = Mail::ExpandAliases->new("/etc/mail/aliases"); |
---|
| 22 | |
---|
| 23 | "new" takes the filename of an aliases file; if not supplied, or if the |
---|
| 24 | file specified does not exist or is not readable, Mail::ExpandAliases |
---|
| 25 | will look in a predetermined set of default locations and use the first |
---|
| 26 | one found. See the section on "ALIAS FILE LOCATIONS", below, for details |
---|
| 27 | on this search path and how to modify it. |
---|
| 28 | |
---|
| 29 | Lookups are made using the "expand" method: |
---|
| 30 | |
---|
| 31 | @aliases = $ma->expand("listname"); |
---|
| 32 | |
---|
| 33 | "expand" returns a list of expanded addresses, sorted alphabetically. |
---|
| 34 | These expanded addresses are also expanded, whenever possible. |
---|
| 35 | |
---|
| 36 | A non-expandible alias (no entry in the aliases file) expands to itself, |
---|
| 37 | i.e., does not expand. |
---|
| 38 | |
---|
| 39 | In scalar context, "expand" returns a reference to a list. |
---|
| 40 | |
---|
| 41 | Note that Mail::ExpandAliases provides read-only access to the alias |
---|
| 42 | file. If you are looking for read access, see Mail::Alias, which is a |
---|
| 43 | more general interface to alias files. |
---|
| 44 | |
---|
| 45 | Mail::ExpandAliases make a resonable attempt to handle aliases the way |
---|
| 46 | "sendmail" does, including loop detection and support for escaped named. |
---|
| 47 | See chapter 24, "Aliases", in *Sendmail* |
---|
| 48 | (<http://www.oreilly.com/catalog/sendmail/>) for full details about this |
---|
| 49 | process. |
---|
| 50 | |
---|
| 51 | ALIAS FILE LOCATIONS |
---|
| 52 | Paths to the aliases file can be added globally at compile time: |
---|
| 53 | |
---|
| 54 | use Mail::ExpandAliases qw(/etc/exim/aliases); |
---|
| 55 | |
---|
| 56 | Alias file locations can also be specified to instances when they are |
---|
| 57 | constructed: |
---|
| 58 | |
---|
| 59 | my $ma = Mail::ExpandAliases->new("/etc/exim/aliases"); |
---|
| 60 | |
---|
| 61 | Alias file locations are stored in the package global |
---|
| 62 | @POSSIBLE_ALIAS_FILES, which can be assigned to directly if you're not |
---|
| 63 | impressed with encapsulation: |
---|
| 64 | |
---|
| 65 | @Mail::ExpandAliases::POSSIBLE_ALIAS_FILES = ("/etc/aliases"); |
---|
| 66 | |
---|
| 67 | By default, @POSSIBLE_ALIAS_FILES contains /etc/aliases, |
---|
| 68 | /etc/mail/aliases, /etc/postfix/aliases, and /etc/exim/aliases. If your |
---|
| 69 | alias file is ones of these, the filename can be omitted from the |
---|
| 70 | constructor; Mail::ExpandAliases will look in @POSSIBLE_ALIAS_FILES |
---|
| 71 | until it finds a file that exists. |
---|
| 72 | |
---|
| 73 | Note that it is not (necessarily) an error if none of these files |
---|
| 74 | exists. An alias file can be added by passing a filename to the init() |
---|
| 75 | method: |
---|
| 76 | |
---|
| 77 | my $ma = Mail::ExpandAliases->new(); |
---|
| 78 | |
---|
| 79 | # Write a temporary aliases file in /tmp/aliases-$< |
---|
| 80 | $ma->init("/tmp/aliases-$<"); |
---|
| 81 | |
---|
| 82 | Calling expand before setting an alias file will, of course, produce no |
---|
| 83 | useful expansions. |
---|
| 84 | |
---|
| 85 | If the constructor is called with the name of a file that exists but |
---|
| 86 | cannot be opened, Mail::ExpandAliases will die with an error detailing |
---|
| 87 | the problem. |
---|
| 88 | |
---|
| 89 | BUGS / SHORTCOMINGS |
---|
| 90 | If you were telnet mailhost 25, and the server had EXPN turned on, then |
---|
| 91 | sendmail would read a user's .forward file. This software cannot do |
---|
| 92 | that, and makes no attempt to. Only the invoking user's .forward file |
---|
| 93 | should be readable (if any other user's .forward file was readable, |
---|
| 94 | sendmail would not read it, making this feature useless), and the |
---|
| 95 | invoking user should not need this module to read their own .forward |
---|
| 96 | file. |
---|
| 97 | |
---|
| 98 | Any other shortcomings, bugs, errors, or generally related complaints |
---|
| 99 | and requests should be reported via the appropriate queue at |
---|
| 100 | <http://rt.cpan.org/>. |
---|
| 101 | |
---|
| 102 | AUTHOR |
---|
| 103 | darren chamberlain <darren@cpan.org> |
---|
| 104 | |
---|