Added -header-field switch to mhmail.
[mmh] / test / post / test-mhmail
index ce4d9c6..5cabc1a 100755 (executable)
@@ -77,13 +77,14 @@ Usage: mhmail [addrs ... [switches]]
   -b(ody) text
   -c(c) addrs ...
   -f(rom) addr
+  -hea(der-field) name:field [-hea(der-field) name:field] ...
   -su(bject) text
   -r(esent)
   -pr(ofile)
   -se(nd)
   -nose(nd)
   -v(ersion)
-  -h(elp)
+  -hel(p)
   and all post(8)/send(1) switches
 EOF
 
@@ -239,7 +240,8 @@ QUIT
 EOF
 
 test_mhmail "$expected" \
-    "-from sender@localhost -cc recipient2@example.com recipient3@example.com recipient4@example.com" '|' message
+    '-from sender@localhost -cc recipient2@example.com recipient3@example.com '\
+'recipient4@example.com' '|' message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -260,8 +262,7 @@ message
 QUIT
 EOF
 
-test_mhmail "$expected" \
-  "-from sender@localhost -subject Test" '|' message
+test_mhmail "$expected" '-from sender@localhost -subject Test' '|' message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -287,8 +288,7 @@ message
 QUIT
 EOF
 
-test_mhmail "$expected" \
-  "-from sender@localhost -profile" '|' message
+test_mhmail "$expected" '-from sender@localhost -profile' '|' message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -309,8 +309,8 @@ message
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost -from sender2@localhost \
--subject Subject1 -subject Subject2" -b message
+test_mhmail "$expected" '-from sender@localhost -from sender2@localhost '\
+'-subject Subject1 -subject Subject2' -b message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 # check repeated -body arguments
@@ -352,8 +352,8 @@ message
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost \
--cc cc1@example.com -cc cc2@example.com" -b message
+test_mhmail "$expected" \
+  '-from sender@localhost -cc cc1@example.com -cc cc2@example.com' -b message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -377,8 +377,9 @@ message
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost \
--cc cc1@example.com -subject Test cc2@example.com" -b message
+test_mhmail "$expected" \
+  '-from sender@localhost -cc cc1@example.com -subject Test cc2@example.com' \
+  -b message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -417,7 +418,7 @@ Date:
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" '|' '\n'
+test_mhmail "$expected" '-from sender@localhost' '|' '\n'
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -439,7 +440,7 @@ Date:
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" '|' '\n\n\n'
+test_mhmail "$expected" '-from sender@localhost' '|' '\n\n\n'
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -459,7 +460,7 @@ no newline in input
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" '|' 'no newline in input'
+test_mhmail "$expected" '-from sender@localhost' '|' 'no newline in input'
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -481,7 +482,7 @@ here's some text
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" '|' "here's some text\n\n\n"
+test_mhmail "$expected" '-from sender@localhost' '|' "here's some text\n\n\n"
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -501,7 +502,7 @@ Date:
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" -b ''
+test_mhmail "$expected" '-from sender@localhost' -b ''
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -522,7 +523,7 @@ Date:
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" -b '
+test_mhmail "$expected" '-from sender@localhost' -b '
 '
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
@@ -547,7 +548,7 @@ Date:
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" -b '
+test_mhmail "$expected" '-from sender@localhost' -b '
 
 
 '
@@ -570,7 +571,7 @@ no newline in input
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" -b 'no newline in input'
+test_mhmail "$expected" '-from sender@localhost' -b 'no newline in input'
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
@@ -593,7 +594,7 @@ here's some text
 QUIT
 EOF
 
-test_mhmail "$expected" "-from sender@localhost" -b "here's some text
+test_mhmail "$expected" '-from sender@localhost' -b "here's some text
 
 "
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
@@ -603,29 +604,138 @@ test_mhmail "$expected" "-from sender@localhost" -b "here's some text
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
-MAIL FROM:<recipient@example.com>
+MAIL FROM:<orig_recipient@example.com>
 RCPT TO:<recipient@example.com>
 DATA
 Resent-To: recipient@example.com
-Resent-From: recipient@example.com
+Resent-From: orig_recipient@example.com
 To: recipient@example.com
 From: sender@localhost
 Date:
 Resent-Date:
 
-please resend this message
+please resend this message, #1
+.
+QUIT
+EOF
+
+test_mhmail "$expected" '-from orig_recipient@example.com -resent' \
+  -b 'To: recipient@example.com
+From: sender@localhost
+Date: Sat Jun 16 18:35:15 -0500
+
+please resend this message, #1'
+
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+# check -resent -profile, using stdin
+# Not supported by compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<orig_recipient@example.com>
+RCPT TO:<recipient@example.com>
+DATA
+To: recipient@example.com
+From: sender@localhost
+Date:
+Resent-To: recipient@example.com
+Resent-From: orig_recipient@example.com
+Resent-Date:
 
+please resend this message, #2
 .
 QUIT
 EOF
 
-test_mhmail "$expected" "-from recipient@example.com -resent" \
-  -b "To: recipient@example.com
+test_mhmail "$expected" \
+  '-from orig_recipient@example.com -resent -profile -nomsgid' \
+  '|' 'To: recipient@example.com
 From: sender@localhost
 Date: Sat Jun 16 18:35:15 -0500
 
-please resend this message
-"
+please resend this message, #2'
+
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+
+# check -resent -profile, using -b
+# Not supported by compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<orig_recipient@example.com>
+RCPT TO:<recipient@example.com>
+DATA
+To: recipient@example.com
+From: sender@localhost
+Date:
+Resent-To: recipient@example.com
+Resent-From: orig_recipient@example.com
+Resent-Date:
+
+please resend this message, #3
+.
+QUIT
+EOF
+
+test_mhmail "$expected" \
+  '-from orig_recipient@example.com -resent -profile -nomsgid' \
+  -b 'To: recipient@example.com
+From: sender@localhost
+Date: Sat Jun 16 18:35:15 -0500
+
+please resend this message, #3'
+
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+
+# check -header-field.
+# Not supported by compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<sender@example.com>
+RCPT TO:<recipient@example.com>
+DATA
+To: recipient@example.com
+From: sender@example.com
+User-Agent: nmh
+Date:
+
+with added header field
+.
+QUIT
+EOF
+
+test_mhmail "$expected" \
+  '-from sender@example.com -header-field User-Agent:nmh' \
+  -b 'with added header field'
+
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+
+# check multiple -header-fields.
+# Not supported by compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<sender@example.com>
+RCPT TO:<recipient@example.com>
+DATA
+To: recipient@example.com
+From: sender@example.com
+MIME-Version: 1.0
+Content-Type: text/plain;charset=utf-8
+Content-Transfer-Encoding: 8bit
+Date:
+
+with added header fields
+.
+QUIT
+EOF
+
+test_mhmail "$expected" \
+  "-from sender@example.com -header-field MIME-Version:1.0 \
+-header-field Content-Type:text/plain;charset=utf-8 \
+-header-field Content-Transfer-Encoding:8bit" \
+  -b 'with added header fields'
 
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}