From 26d1d48706344c9311fe19f3691e5c0a230da710 Mon Sep 17 00:00:00 2001 From: David Levine Date: Tue, 19 Jun 2012 10:13:28 -0500 Subject: [PATCH] Added -attach switch to mhmail. --- Makefile.am | 3 ++- man/mhmail.man | 31 +++++++++++++++++++++++++++++++ test/common.sh.in | 1 + test/mhmail/test-mhmail | 45 ++++++++++++++++++++++++++++++++++++++++++++- test/mhparam/test-mhparam | 2 +- uip/mhmail | 32 ++++++++++++++++++++++++-------- 6 files changed, 103 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 970eb60..3f56a70 100644 --- a/Makefile.am +++ b/Makefile.am @@ -226,7 +226,8 @@ EXTRA_DIST = config/version.sh sbr/sigmsg.awk etc/mts.conf.in etc/sendfiles.in \ man/unseen.man man/whatnow.man man/whom.man \ test/README $(TESTS) test/inc/deb359167.mbox \ test/inc/fromline.txt test/inc/msgheader.txt test/inc/filler.txt \ - test/inc/md5sums test/post/test-post-common.sh uip/mhmail \ + test/inc/md5sums test/mhmail/attachment.txt \ + test/post/test-post-common.sh uip/mhmail \ SPECS/nmh.spec SPECS/build-nmh-cygwin ## diff --git a/man/mhmail.man b/man/mhmail.man index 3abd6d3..3b382af 100644 --- a/man/mhmail.man +++ b/man/mhmail.man @@ -10,6 +10,8 @@ mhmail \- send or read mail .B mhmail .RI [ addrs \&...] +.RB [ \-attach +.IR file ] .RB [ \-body .IR text ] .RB [ \-cc @@ -143,6 +145,14 @@ recipient@example.com .fi .RE .PP +Note about this example: the +.B \-attach +switch causes +.I MIME-Version +and +.I Content-Type +headers to be added to the message. +.PP The .B \-profile switch instructs @@ -154,6 +164,22 @@ instead of to send the message. This allows use of the user's context and aliases. .PP The +.B \-attach +.I file +switch attaches the specified file to the message. Use of +.B \-attach +enables +.B \-profile +because +.B mhmail +uses +.B send +to handle the attachment. It is usually best to enclose the argument +in quotes to protect it from the shell. The +.B \-attach +switch may be given multiple times to add multiple attachments. +.PP +The .B \-nosend option shows the draft file that would be posted/sent on the command's standard output but does not post or send it. @@ -186,7 +212,12 @@ is used. dist(1), inc(1), post(8), send(1) .SH DEFAULTS +.nf .RB ` \-send ' +.fi +.RB ` \-profile' , +enabled by default only with +.B \-attach .SH CONTEXT If diff --git a/test/common.sh.in b/test/common.sh.in index e5da52c..aa34927 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -161,6 +161,7 @@ setup_test () mkdir $MH_TEST_DIR/Mail || exit 1 cat > $MH < "$actual".nodate + -e 's/^Message-ID:.*/Message-ID:/' \ + -e 's/^Content-ID:.*/Content-ID:/' "$actual" > "$actual".nodate rm -f "$actual" check "$actual".nodate "$1" @@ -74,6 +75,7 @@ actual_err=$MH_TEST_DIR/test-mhmail$$.actual_err cat >$expected < "$expected" < +RCPT TO: +DATA +To: recipient@example.com +From: sender@example.com +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" +Content-ID: +Date: +Message-ID: + +------- =_aaaaaaaaaa0 +Content-Type: text/plain; charset="us-ascii" + +See how easy it is to add an attachment! + +------- =_aaaaaaaaaa0 +Content-Type: text/plain; name="attachment.txt"; charset="us-ascii" +Content-Description: attachment.txt +Content-Disposition: attachment; filename="attachment.txt" + +The future disappears into memory, With only a moment between, +Forever dwells in that moment, hope is what remains to be seen +Forever dwells in that moment, hope is what remains to be seen. + +------- =_aaaaaaaaaa0-- +. +QUIT +EOF + +test_mhmail "$expected" \ + "-from sender@example.com -attach ${srcdir}/test/mhmail/attachment.txt" \ + -b 'See how easy it is to add an attachment!' + +[ ${failed:-0} -eq 0 ] || exit ${failed:-0} + + exit ${failed:-0} diff --git a/test/mhparam/test-mhparam b/test/mhparam/test-mhparam index cde481c..a56945c 100755 --- a/test/mhparam/test-mhparam +++ b/test/mhparam/test-mhparam @@ -79,7 +79,7 @@ AliasFile: aliases" cat >$expected <