Add new "expandaddr" flag (disabled by default) to enable recipient address expansion and document it. Index: usr.bin/mail/mail.1 =================================================================== --- usr.bin/mail/mail.1.orig +++ usr.bin/mail/mail.1 @@ -303,6 +303,47 @@ System wide aliases are not expanded when the mail is sent, but any reply returned to the machine will have the system wide alias expanded as all mail goes through an MTA. +.Ss Recipient address specifications +Recipient addresses (any of the +.Dq To , +.Dq Cc +or +.Dq Bcc +header fields) are subject to expansion when the +.Ic expandaddr +option is set. +.Pp +An address may be expanded as follows: +.Bl -bullet -width Ds +.It +An address that starts with a pipe +.Pq Ql | +character is treated as a command to run. +The command immediately following the +.Ql | +is executed with the message as its standard input. +.It +An address that starts with a +.Ql + +character is treated as a folder. +.It +An address that contains a +.Ql / +character but no +.Ql \&! , +.Ql % , +or +.Ql @ +characters is also treated as a folder. +.It +If none of the above apply, the recipient is treated as +a local or network mail address. +.El +.Pp +If the +.Ic expandaddr +option is not set (the default), no expansion is performed and +the recipient is treated as a local or network mail address. .Ss Network mail (ARPA, UUCP, Berknet) See .Xr mailaddr 7 @@ -920,6 +961,11 @@ causes .Nm mail to interpret a period alone on a line as the terminator of a message you are sending. +.It Ar expandaddr +Causes +.Nm mail +to expand message recipient addresses, as explained in the section +.Sx Recipient address specifications . .It Ar hold This option is used to hold messages in the system mailbox by default. Index: usr.bin/mail/names.c =================================================================== --- usr.bin/mail/names.c.orig +++ usr.bin/mail/names.c @@ -209,6 +209,9 @@ outof(struct name *names, FILE *fo, stru char *date, *fname; FILE *fout, *fin; + if (value("expandaddr") == NULL) + return(names); + top = names; np = names; (void)time(&now);