NAME

Mail::Alias::Reader - Read aliases(5) and ~/.forward declarations

SYNOPSIS

my $reader = Mail::Alias::Reader->open(
    'handle' => \*STDIN,
    'mode'   => 'aliases'
);

while (my ($name, $destinations) = $reader->read) {
    my @addresses = grep { $_->is_address } @{$destinations};

    print "$name: " . join(', ', map { $_->to_string } @addresses) . "\n";
}

$reader->close;

DESCRIPTION

Mail::Alias::Reader is a small but oddly flexible module that facilitates the reading of aliases(5)-style mail alias and ~/.forward declarations. It does not directly provide support for the writing and in-memory manipulation of these files as a whole, however its limited feature set may be considered to be a virtue.

The module can read mail aliases or ~/.forward declarations from a file, or from an arbitrary file handle, as specified at the time of file reader instantiation. The destination objects returned are the same parser tokens used internally, keeping code footprint low without being too much of a hassle.

STARTING UP THE MODULE

READING DECLARATIONS

THE MAIL DESTINATION TOKEN

Mail destination objects returned by $reader->read() are HASH objects bless()ed into the Mail::Alias::Reader::Token package, and contain a small handful of data attributes, but can be inspected with a variety of helper functions in the form of instance methods. Please see the Mail::Alias::Reader::Token documentation for a listing of these helper functions.

The mail destination attributes include:

CLOSING THE STREAM

ERROR HANDLING

Carp::confess() is used internally for passing any error conditions detected during the runtime of this module.

AUTHOR

Written and maintained by Xan Tronix xan@cpan.org.

COPYRIGHT

Copyright (c) 2014, cPanel, Inc. All rights reserved. http://cpanel.net/

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See the LICENSE file for further details.