X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/cc8630bbb299b1107e0bf5874f52c75b4c19b8c4..8a0176e1ef5612725f97baec519775c72468ab55:/test/mhmail/test-mhmail diff --git a/test/mhmail/test-mhmail b/test/mhmail/test-mhmail index 43f4cc71..ff9fd40b 100755 --- a/test/mhmail/test-mhmail +++ b/test/mhmail/test-mhmail @@ -14,6 +14,21 @@ fi . "${srcdir}/test/post/test-post-common.sh" +# Find MIME type string, using configured procs if available. +MIMETYPEPROC=`mhparam mimetypeproc` +MIMEENCODINGPROC=`mhparam mimeencodingproc` +content_type_string() { + if test -z "$MIMETYPEPROC" -o -z "$MIMEENCODINGPROC"; then + #### This should be the order of name and charset. + echo "text/plain; name=\"`basename $1`\"; charset=\"us-ascii\"" + else + #### Excise any leading filename followed by : and whitespace. + printf '%s; charset="%s"; name="%s"' \ + `$MIMETYPEPROC $1 | sed -e 's/.*: *//'` \ + `$MIMEENCODINGPROC $1 | sed -e 's/.*: *//'` `basename $1` + fi +} + # Customize test_post () for use with mhmail. # $1 is expected output file, provided by caller # $2 is mhmail switches, except for -body @@ -38,11 +53,6 @@ test_mhmail () # Message-ID. # -ls -l $actual >&2 # ???? temporary -echo actual: -cat $actual -echo end of actual - sed -e 's/^Date:.*/Date:/' \ -e 's/^Resent-Date:.*/Resent-Date:/' \ -e 's/^Message-ID:.*/Message-ID:/' "$actual" > "$actual".nodate @@ -119,12 +129,12 @@ esac # check -nosend # Not supported by compiled mhmail. -mhmail -nosend recipient@example.com -from sender@localhost \ +mhmail -nosend recipient@example.com -from sender1@localhost \ -server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err" cat > "$expected" < "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender2@localhost Date: message @@ -153,7 +163,7 @@ message QUIT EOF -test_mhmail "$expected" "-from sender@localhost -nosend -send" '|' message +test_mhmail "$expected" "-from sender2@localhost -nosend -send" '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -161,11 +171,11 @@ test_mhmail "$expected" "-from sender@localhost -nosend -send" '|' message # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender3@localhost Date: message @@ -173,7 +183,7 @@ message QUIT EOF -test_mhmail "$expected" "-from sender@localhost" '|' message +test_mhmail "$expected" "-from sender3@localhost" '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -181,11 +191,11 @@ test_mhmail "$expected" "-from sender@localhost" '|' message # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender4@localhost Date: body @@ -193,7 +203,7 @@ body QUIT EOF -test_mhmail "$expected" "-from sender@localhost" -b body +test_mhmail "$expected" "-from sender4@localhost" -b body [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -201,13 +211,13 @@ test_mhmail "$expected" "-from sender@localhost" -b body # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: RCPT TO: DATA To: recipient@example.com Cc: recipient2@example.com -From: sender@localhost +From: sender5@localhost Date: message @@ -216,7 +226,7 @@ QUIT EOF test_mhmail "$expected" \ - "-from sender@localhost -cc recipient2@example.com" '|' message + "-from sender5@localhost -cc recipient2@example.com" '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -224,7 +234,7 @@ test_mhmail "$expected" \ # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: RCPT TO: RCPT TO: @@ -233,7 +243,7 @@ DATA To: recipient@example.com Cc: recipient2@example.com, recipient3@example.com, recipient4@example.com -From: sender@localhost +From: sender6@localhost Date: message @@ -242,8 +252,8 @@ QUIT EOF test_mhmail "$expected" \ - '-from sender@localhost -cc recipient2@example.com recipient3@example.com '\ -'recipient4@example.com' '|' message + '-from sender6@localhost -cc recipient2@example.com '\ +'recipient3@example.com recipient4@example.com' '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -251,12 +261,12 @@ test_mhmail "$expected" \ # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com Subject: Test -From: sender@localhost +From: sender7@localhost Date: message @@ -264,7 +274,7 @@ message QUIT EOF -test_mhmail "$expected" '-from sender@localhost -subject Test' '|' message +test_mhmail "$expected" '-from sender7@localhost -subject Test' '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -277,11 +287,13 @@ printf 'send: -msgid\n' >> $MH cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender8@localhost +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" Date: Message-ID: @@ -290,7 +302,7 @@ message QUIT EOF -test_mhmail "$expected" '-from sender@localhost -profile' '|' message +test_mhmail "$expected" '-from sender8@localhost -profile' '|' message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -298,12 +310,12 @@ test_mhmail "$expected" '-from sender@localhost -profile' '|' message # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com Subject: Subject2 -From: sender2@localhost +From: sender9@localhost Date: message @@ -311,7 +323,7 @@ message QUIT EOF -test_mhmail "$expected" '-from sender@localhost -from sender2@localhost '\ +test_mhmail "$expected" '-from sender9@localhost -from sender9@localhost '\ '-subject Subject1 -subject Subject2' -b message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -319,11 +331,11 @@ test_mhmail "$expected" '-from sender@localhost -from sender2@localhost '\ # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender10@localhost Date: body2 @@ -331,7 +343,7 @@ body2 QUIT EOF -test_mhmail "$expected" "-from sender@localhost -body body1" -b body2 +test_mhmail "$expected" "-from sender10@localhost -body body1" -b body2 [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -339,14 +351,14 @@ test_mhmail "$expected" "-from sender@localhost -body body1" -b body2 # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: RCPT TO: RCPT TO: DATA To: recipient@example.com Cc: cc1@example.com, cc2@example.com -From: sender@localhost +From: sender11@localhost Date: message @@ -355,7 +367,7 @@ QUIT EOF test_mhmail "$expected" \ - '-from sender@localhost -cc cc1@example.com -cc cc2@example.com' -b message + '-from sender11@localhost -cc cc1@example.com -cc cc2@example.com' -b message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -363,7 +375,7 @@ test_mhmail "$expected" \ # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: RCPT TO: RCPT TO: @@ -371,7 +383,7 @@ DATA To: recipient@example.com Cc: cc1@example.com, cc2@example.com Subject: Test -From: sender@localhost +From: sender12@localhost Date: message @@ -380,8 +392,8 @@ QUIT EOF test_mhmail "$expected" \ - '-from sender@localhost -cc cc1@example.com -subject Test cc2@example.com' \ - -b message + '-from sender12@localhost -cc cc1@example.com -subject '\ +'Test cc2@example.com' -b message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -389,7 +401,7 @@ test_mhmail "$expected" \ # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: RCPT TO: RCPT TO: @@ -397,7 +409,7 @@ DATA To: recipient@example.com, recipient2@example.com Cc: cc1@example.com Subject: Test -From: sender@localhost +From: sender13@localhost Date: message @@ -406,7 +418,7 @@ QUIT EOF test_mhmail "$expected" \ - "-from sender@localhost -cc cc1@example.com -subject Test \ + "-from sender13@localhost -cc cc1@example.com -subject Test \ -to recipient2@example.com" \ -b message [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -435,11 +447,11 @@ check "$expected_err" "$actual_err" # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender14@localhost Date: @@ -447,7 +459,7 @@ Date: QUIT EOF -test_mhmail "$expected" '-from sender@localhost' '|' ' +test_mhmail "$expected" '-from sender14@localhost' '|' ' ' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -456,11 +468,11 @@ test_mhmail "$expected" '-from sender@localhost' '|' ' # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender15@localhost Date: @@ -470,7 +482,7 @@ Date: QUIT EOF -test_mhmail "$expected" '-from sender@localhost' '|' ' +test_mhmail "$expected" '-from sender15@localhost' '|' ' ' @@ -481,11 +493,11 @@ test_mhmail "$expected" '-from sender@localhost' '|' ' # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender16@localhost Date: no newline in input @@ -493,7 +505,7 @@ no newline in input QUIT EOF -test_mhmail "$expected" '-from sender@localhost' '|' 'no newline in input' +test_mhmail "$expected" '-from sender16@localhost' '|' 'no newline in input' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -501,11 +513,11 @@ test_mhmail "$expected" '-from sender@localhost' '|' 'no newline in input' # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender17@localhost Date: here's some text @@ -515,7 +527,7 @@ here's some text QUIT EOF -test_mhmail "$expected" '-from sender@localhost' '|' "here's some text +test_mhmail "$expected" '-from sender17@localhost' '|' "here's some text " @@ -526,11 +538,11 @@ test_mhmail "$expected" '-from sender@localhost' '|' "here's some text # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender18@localhost Date: @@ -538,7 +550,7 @@ Date: QUIT EOF -test_mhmail "$expected" '-from sender@localhost' -b '' +test_mhmail "$expected" '-from sender18@localhost' -b '' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -546,11 +558,11 @@ test_mhmail "$expected" '-from sender@localhost' -b '' # Shows different behavior than compiled mhmail, which suppressed the newline. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender19@localhost Date: @@ -559,7 +571,7 @@ Date: QUIT EOF -test_mhmail "$expected" '-from sender@localhost' -b ' +test_mhmail "$expected" '-from sender19@localhost' -b ' ' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -569,11 +581,11 @@ test_mhmail "$expected" '-from sender@localhost' -b ' # of the newlines. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender20@localhost Date: @@ -584,7 +596,7 @@ Date: QUIT EOF -test_mhmail "$expected" '-from sender@localhost' -b ' +test_mhmail "$expected" '-from sender20@localhost' -b ' ' @@ -595,11 +607,11 @@ test_mhmail "$expected" '-from sender@localhost' -b ' # Verified same behavior as compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender21@localhost Date: no newline in input @@ -607,7 +619,7 @@ no newline in input QUIT EOF -test_mhmail "$expected" '-from sender@localhost' -b 'no newline in input' +test_mhmail "$expected" '-from sender21@localhost' -b 'no newline in input' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -616,11 +628,11 @@ test_mhmail "$expected" '-from sender@localhost' -b 'no newline in input' # of the newlines. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender22@localhost Date: here's some text @@ -630,7 +642,7 @@ here's some text QUIT EOF -test_mhmail "$expected" '-from sender@localhost' -b "here's some text +test_mhmail "$expected" '-from sender22@localhost' -b "here's some text " [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -646,7 +658,7 @@ DATA Resent-To: recipient@example.com Resent-From: orig_recipient@example.com To: recipient@example.com -From: sender@localhost +From: sender23@localhost Date: Resent-Date: @@ -657,7 +669,7 @@ EOF test_mhmail "$expected" '-from orig_recipient@example.com -resent' \ -b 'To: recipient@example.com -From: sender@localhost +From: sender23@localhost Date: Sat Jun 16 18:35:15 -0500 please resend this message, 1' @@ -672,7 +684,7 @@ MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender24@localhost Date: Resent-To: recipient@example.com Resent-From: orig_recipient@example.com @@ -686,7 +698,7 @@ EOF test_mhmail "$expected" \ '-from orig_recipient@example.com -resent -profile -nomsgid' \ '|' 'To: recipient@example.com -From: sender@localhost +From: sender24@localhost Date: Sat Jun 16 18:35:15 -0500 please resend this message, 2' @@ -702,7 +714,7 @@ MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@localhost +From: sender25@localhost Date: Resent-To: recipient@example.com Resent-From: orig_recipient@example.com @@ -716,7 +728,7 @@ EOF test_mhmail "$expected" \ '-from orig_recipient@example.com -resent -profile -nomsgid' \ -b 'To: recipient@example.com -From: sender@localhost +From: sender25@localhost Date: Sat Jun 16 18:35:15 -0500 please resend this message, 3' @@ -728,11 +740,11 @@ please resend this message, 3' # Not supported by compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@example.com +From: sender26@example.com User-Agent: nmh Date: @@ -742,7 +754,7 @@ QUIT EOF test_mhmail "$expected" \ - '-from sender@example.com -headerfield User-Agent:nmh' \ + '-from sender26@example.com -headerfield User-Agent:nmh' \ -b 'with added header field' [ ${failed:-0} -eq 0 ] || exit ${failed:-0} @@ -752,11 +764,11 @@ test_mhmail "$expected" \ # Not supported by compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@example.com +From: sender27@example.com MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit @@ -768,7 +780,7 @@ QUIT EOF test_mhmail "$expected" \ - "-from sender@example.com -headerfield MIME-Version:1.0 \ + "-from sender27@example.com -headerfield MIME-Version:1.0 \ -headerfield Content-Type:text/plain;charset=utf-8 \ -headerfield Content-Transfer-Encoding:8bit" \ -b 'with added header fields' @@ -780,11 +792,11 @@ test_mhmail "$expected" \ # Not supported by compiled mhmail. cat > "$expected" < +MAIL FROM: RCPT TO: DATA To: recipient@example.com -From: sender@example.com +From: sender28@example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Date: @@ -796,7 +808,7 @@ 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-Type: `content_type_string ${srcdir}/test/mhmail/attachment.txt` Content-Description: attachment.txt Content-Disposition: attachment; filename="attachment.txt" @@ -810,7 +822,7 @@ QUIT EOF test_mhmail "$expected" \ - "-from sender@example.com -attach ${srcdir}/test/mhmail/attachment.txt" \ + "-from sender28@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}