NAME

expand_aliases.pl - Resolves email aliases from a YAML configuration file

SYNOPSIS

./expand_aliases.pl email@example.com team-alias some-group

DESCRIPTION

This script expands email aliases defined in a YAML file into a list of actual email addresses. It helps in managing mailing lists and group communications by maintaining aliases in a central configuration file rather than having to remember individual email addresses.

The script uses the Mail::Alias::LocalFile module to handle the expansion of aliases, including detection and warning about circular references.

REQUIREMENTS

  • Perl 5.10.0 or newer

  • YAML::XS

  • Data::Dumper::Concise

  • Mail::Alias::LocalFile

CONFIGURATION

The script looks for aliases in a YAML file. By default, it uses 'aliases.yml', but the path can be modified by changing the $alias_file_path variable in the script.

Alternative configurations are commented out in the script:

# my $alias_file_path = 'aliases.json';
# my $alias_file_path = 'good_aliases.yml';

Aliases File Format

The aliases file should be in YAML format with the following structure:

alias1:
  - user1@example.com
  - user2@example.com
alias2: user3@example.com, alias1, mta_postmaster

Aliases can refer to other aliases, which will be expanded recursively.

USAGE

./expand_aliases.pl [email addresses and/or aliases...]

OUTPUT

The script outputs:

  • List of expanded recipients

  • Warnings about circular references (if any)

  • Original input list

  • Detailed debug information (when the debug section is uncommented)

TROUBLESHOOTING

Debug information can be enabled by uncommenting the troubleshooting section at the end of the script:

say "=============== START ===============================";
say "result";
say Dumper( $result );
say "================ END  ===============================";

DIAGNOSTICS

  • ERROR: No email recipients and/or aliases were provided

    The script was called without any arguments. You need to provide at least one email address or alias.

  • The aliases.yml file did not load

    There was an error loading the aliases file. Make sure the file exists and contains valid YAML.

  • Warning: the aliases file contains circular references

    The aliases file contains circularity where alias definitions form a loop. This could cause infinite recursion if not handled properly.

EXAMPLES

  • Expand a single alias:

    ./expand_aliases.pl developers
  • Expand multiple aliases and individual addresses:

    ./expand_aliases.pl developers managers john@example.com

AUTHOR

Contact the original author for more information about this script.

SEE ALSO

Mail::Alias::LocalFile, YAML::XS