varstrlst mailParseAliases(varchar aliases, varchar what
                           [, varchar flags])


  • aliases - A varchar string in sendmail /etc/aliases format

  • what - A varchar field indicating what to return:

    • "aliases" - List of entries' aliases (left side)

    • "targets" - List of entries' targets (right side)

    • "types" - List of entries' types: "include", "fail", "pipe", "file", "address"

  • flags - An optional CSV list of flags:

    • "includes" - Parse include files (default)

    • "noincludes" - Do not parse include files


  • A varstrlst list of aliases, targets or types

The mailParseAliases function returns a list of aliases, their targets, or their types, as requested, from an /etc/aliases-style string buffer. The lists are parallel; thus a multi-target alias will be "denormalized" and cause that alias to be returned multiple times, once per target (see alias "foo" in the example).

By default (or if the "includes" flag is given), :include: targets will be read and processed as such. If the "noincludes" flag is given, includes will not be processed and will be returned as type "include".


# This is a comment.
postmaster:     root
"foo":          bar,, 'joe blow'
nobody:         :fail:No such user
spam:           /dev/null
orders:         |/some/program
  <$aliasBuf = $ret>
  <$aliases = (mailParseAliases($aliasBuf, "aliases" ))>
  <$types = (mailParseAliases($aliasBuf, "types" ))>
  <$targets = (mailParseAliases($aliasBuf, "targets" ))>
  <loop $aliases $types $targets>
    Entry $aliases: Type $types, target is $targets

The output would be:

Entry postmaster: Type address, target is root
Entry foo: Type address, target is bar
Entry foo: Type address, target is
Entry foo: Type address, target is joe blow
Entry nobody: Type fail, target is No such user
Entry spam: Type file, target is /dev/null
Entry orders: Type pipe, target is /some/program

Copyright © Thunderstone Software     Last updated: Dec 10 2018
Copyright © 2019 Thunderstone Software LLC. All rights reserved.