MH-ALIAS(5)

πŸ’– MH-ALIAS πŸ’–

okay so bestie, gather round, because we're about to talk about mh-alias β€” that's the format of nmh email-address alias files, and honestly? it's giving ✨ancient scroll of power✨. no cap, this is the file that tells nmh who's who before your mail goes anywhere.


🌸 DESCRIPTION 🌸

every single line of an nmh alias file is one of these shapes, periodt:

     alias : address-group

     alias ; address-group

     < alias-file

     ; | : | # comment

and where those pieces come from:

     address-group  := address-list
                    |  < file

     address-list   := address
                    |  address-list, address

continuation lines? they end with \ and then a newline character. yes queen, keep going on the next line. and that goes for comment lines too, which means the line right after a \-terminated comment line is a continuation of that same comment line. so like, comments can vibe across multiple lines. πŸ’…

Alias-file and file are Unix file names. alias file contents are case-insensitive, with one exception: filesystem path names stay case-sensitive, obviously, they have a job.

if a line starts with <, the file named right after that < gets read for more alias definitions. and it's recursive, so a < can show up at the beginning of an alias file and everything just works the way you'd expect. πŸ¦‹

if the address-group starts with a <, the file named after it gets read and its contents get added to the address-list for that alias. two different < behaviours, both iconic, don't mix them up.

in matching, a trailing * on an alias will match just about anything appropriate. wildcard main character energy.

here's an approximation of how aliases get resolved at posting time β€” the whole pipeline, no skips:

  1. build a list of all addresses from the message to be delivered, eliminating duplicate addresses.
  2. for those addresses in the message that have no host specified, perform alias resolution.
  3. for each line in the alias file, compare alias against all of the existing addresses. if there's a match, remove the matched alias from the address list, and add each new address in the address-group to the address list if it's not already on the list. the alias itself is not usually output β€” instead, the address-group that the alias maps to is what gets output. but if alias is terminated with a ; instead of a :, then both the alias and the address are output in the correct format (with the alias quoted if necessary and the address wrapped in <>). πŸ’…

and because the mh-alias file is read line by line, forward references work, but backward references are not recognized. read top to bottom, bestie, no looking back. πŸ™ˆ

πŸ“ Example Alias File

     </etc/nmh/BBoardAliases
     sgroup: fred, fear, freida
     fred: frated@UCI.example
     b-people: Blind List: bill, betty
     Unix-committee: <unix.aliases
     news.*: news

okay let's break this down because it's honestly so cute:

  • the first line says more aliases should immediately be read from the file /etc/nmh/BBoardAliases.
  • next, sgroup is defined as an alias for three names, and one of them, fred, is a forward reference to another alias for frated@UCI.example. forward refs slay, remember?
  • the alias b-people is a blind list which includes the addresses bill and betty; the message will be delivered to those addresses, but the message header will show only Blind List: ; (not the addresses). the alias must not be terminated with, or contain, a semicolon. and heads up β€” blind lists are not supported with the sendmail/pipe mail transport method. that one's a real limitation, don't come for me.
  • the definition of Unix-committee is given by reading the file unix.aliases in the user's nmh directory.
  • lastly, news.anything is aliased to news; the full stop is just another literal character. not a regex, not a wildcard, just a dot doing its little dot thing. ⭐

πŸŽ€ PROFILE COMPONENTS πŸŽ€

  • Aliasfile: β€” default alias file. that's the whole list, she's low maintenance.

πŸ“‚ FILES πŸ“‚

  • /etc/nmh/MailAliases β€” system-wide default alias file.

πŸ‘€ SEE ALSO πŸ‘€

ali(1), send(1), whom(1), getgrent(3), getpwent(3), post(8)

go read those too, they're the friend group. 🫢


πŸ’€ BUGS πŸ’€

  • so, the forward-referencing semantics of mh-alias files prevent recursion... but the alias-file directive may defeat this. and since the number of file descriptors is finite, that kind of infinite recursion will terminate with a meaningless diagnostic when all the fds are used up. not a graceful exit, bestie, just chaos. πŸ’€
  • earlier versions of this man page showed a semicolon at the end of the blind list example. that caused the preceding alias to not be expanded. there must not be a semicolon at the end of, or within, the address group of a blind list. post will append the semicolon to the blind list name.

fr fr, that's the whole page. no details left behind, every flag, file, and footgun accounted for. πŸ’–

mwah πŸ’‹ this was nmh-1.8, dated 2014-04-18, and that's the MH-ALIAS(5) page β€” thanks for coming to my ted talk, ily, go alias responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from