From 5200594b19e81959d1d249e9feaad4ec0b02f5c2 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 23 Jun 2012 09:55:01 -0500 Subject: [PATCH] Allow optional -to in front of To: addresses with mhmail. --- man/mhmail.man | 39 +++++++++++++++++++++++++++------------ test/mhmail/test-mhmail | 44 ++++++++++++++++++++++++++++++++++++-------- uip/mhmail | 13 ++++++++++--- 3 files changed, 73 insertions(+), 23 deletions(-) diff --git a/man/mhmail.man b/man/mhmail.man index a374b3d..6eacf16 100644 --- a/man/mhmail.man +++ b/man/mhmail.man @@ -8,8 +8,9 @@ mhmail \- send or read mail .HP 5 .na .B mhmail -.RI [ addrs -\&...] +.RB [ \-to ] +.RI addrs +\&... .RB [ \-attach .IR file ] .RB [ \-body @@ -34,6 +35,11 @@ mhmail \- send or read mail .RB [ \-send " | " \-nosend ] .RB [ \-version ] .RB [ \-help ] +.PP +.HP 5 +.B mhmail +with no arguments is equivalent to +.B inc .ad .SH DESCRIPTION .B mhmail @@ -46,8 +52,8 @@ which is compatible with .BR nmh . This program is intended for the use of programs such as .BR cron , -which expect to send mail automatically to various -users. It is also used by various +which expect to send mail automatically to various addresses. It is +also used by various .B nmh commands to mail various error notifications. Although @@ -61,15 +67,15 @@ be used instead to send messages. .PP When invoked without arguments, it simply invokes .B inc -to incorporate new messages from the user's maildrop. When one or more users -is specified, a message is read from the standard input and spooled to -a temporary file. +to incorporate new messages from the user's maildrop. +.PP +When one or more addresses are specified, a message is read from the +standard input and spooled to a temporary file. .B mhmail then invokes -.B post -with the -name of the temporary file as its argument to deliver the message to -the specified user. +.BR post , +by default, with the name of the temporary file as its argument to +deliver the message to the specified address. .PP The .B \-subject @@ -109,7 +115,16 @@ field. At least one such address is required when sending a message, i.e., if any other switches are supplied. If the .B \-cc switch is used, all addresses following it, even if there are -intervening switches, are placed in the \*(lqcc:\*(rq field. +intervening switches other than +.BR \-to , +are placed in the \*(lqcc:\*(rq field. The optional +.B \-to +switch can appear in front of any addresses to signify their placement +in the \*(lqTo:\*(rq field. The +.B \-to +and +.B \-cc +switches may be given multiple times. .PP By using .B \-from diff --git a/test/mhmail/test-mhmail b/test/mhmail/test-mhmail index 80e95c5..5a7117b 100755 --- a/test/mhmail/test-mhmail +++ b/test/mhmail/test-mhmail @@ -73,7 +73,7 @@ actual_err=$MH_TEST_DIR/test-mhmail$$.actual_err # check -help # Verified behavior consistent with compiled sendmail. cat >$expected <$actual 2>&1 @@ -103,21 +104,21 @@ case `mhmail -v` in esac # check for missing argument to switches that require them -for switch in attach body cc from headerfield subject; do +for switch in attach body cc from headerfield subject to; do run_test "mhmail recipient -$switch" \ "mhmail: missing argument to -$switch" done -for switch in attach body cc from headerfield subject; do +for switch in attach body cc from headerfield subject to; do run_test "mhmail recipient -$switch -nosend" \ "mhmail: missing argument to -$switch" done -for switch in attach body cc from headerfield subject; do +for switch in attach body cc from headerfield subject to; do run_test "mhmail recipient -$switch -server 127.0.0.1" \ "mhmail: missing argument to -$switch" done -# check with no arguments +# check with no switches # That will just run inc, which we don't want to do anything, # so tell inc to just display its version. # Verified same behavior as compiled mhmail. @@ -308,7 +309,7 @@ test_mhmail "$expected" '-from sender@localhost -profile' '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} -# check repeated -from and -subject arguments +# check repeated -from and -subject switches # Verified same behavior as compiled mhmail. cat > "$expected" < "$expected" < "$expected" < "$expected" < +RCPT TO: +RCPT TO: +RCPT TO: +DATA +To: recipient@example.com, recipient2@example.com +Cc: cc1@example.com +Subject: Test +From: sender@localhost +Date: + +message +. +QUIT +EOF + +test_mhmail "$expected" \ + "-from sender@localhost -cc cc1@example.com -subject Test \ + -to recipient2@example.com" \ + -b message +[ ${failed:-0} -eq 0 ] || exit ${failed:-0} + + # check with no newline on stdin # Shows different behavior than compiled mhmail, which was silent in this case. cat > "$expected" <