. "${srcdir}/test/post/test-post-common.sh"
-# Find MIME type string, using mimetypeproc if configured with it.
+# Find MIME type string, using configured procs if available.
MIMETYPEPROC=`mhparam mimetypeproc`
+MIMEENCODINGPROC=`mhparam mimeencodingproc`
content_type_string() {
- if test -z "$MIMETYPEPROC"; then
+ 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
- # 1) Excise leading filename followed by : and any whitespace.
- # 2) Insert semicolon if there isn't one before the first space.
- # OpenBSD file --mime spits out things like "text/plain charset=...".
- # 3) Wrap charset value in double quotes. Assume that it isn't already.
- printf "%s %s%s" \
- `$MIMETYPEPROC $1 | sed -e 's/.*: *//' -e 's/\([^;]\) /\1; /' \
- -e 's/\(charset=\)\(.*\)/\1"\2"/'` "; name=\"`basename $1`\""
+ #### 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
}
# check -help
+start_test "-help"
# Verified behavior consistent with compiled sendmail.
cat >$expected <<EOF
Usage: mhmail [-t(o)] addrs ... [switches]
mhmail with no arguments is equivalent to inc
EOF
-mhmail -help >$actual 2>&1
-check $expected $actual
+#### Skip nmh intro text.
+mhmail -help 2>&1 | sed '/^$/,$d' >"$actual"
+check "$expected" "$actual"
# check -version
+start_test "-version"
# Verified same behavior as compiled mhmail.
case `mhmail -v` in
mhmail\ --*) ;;
esac
# check for missing argument to switches that require them
+start_test "for missing argument to switches that require them"
for switch in attach body cc from headerfield subject to; do
run_test "mhmail recipient -$switch" \
"mhmail: missing argument to -$switch"
# check with no switches
+start_test "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.
# check -nosend
+start_test "-nosend"
# Not supported by compiled mhmail.
mhmail -nosend recipient@example.com -from sender1@localhost \
-server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err"
# check -send
+start_test "-send"
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from
+start_test "-from"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from and -body
+start_test "-from and -body"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from and -cc
+start_test "-from and -cc"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from and multiple -cc addresses
+start_test "-from and multiple -cc addresses"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from and -subject
+start_test "-from and -subject"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -from and -profile
+start_test "-from and -profile"
# Show that -profile causes mhmail to 1) read the profile and
# 2) use send(1) by added a send switch to the profile and
# verifying that it gets used.
DATA
To: recipient@example.com
From: sender8@localhost
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
Date:
Message-ID:
# check repeated -from and -subject switches
+start_test "repeated -from and -subject switches"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
# check repeated -body switches
+start_test "repeated -body switches"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check multiple -cc switches
+start_test "multiple -cc switches"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check separated -cc arguments
+start_test "separated -cc arguments"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -cc switch followed by -to switch
+start_test "-cc switch followed by -to switch"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with no newline on stdin
+start_test "with no newline on stdin"
# Shows different behavior than compiled mhmail, which was silent in this case.
cat > "$expected" <<EOF
EOF
# check with one newline on stdin
+start_test "with one newline on stdin"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with multiple newlines on stdin
+start_test "with multiple newlines on stdin"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with text and no trailing newline on stdin
+start_test "with text and no trailing newline on stdin"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with text and multiple trailing blank lines on stdin
+start_test "with text and multiple trailing blank lines on stdin"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with no newline to -body
+start_test "with no newline to -body"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with one newline to -body
+start_test "with one newline to -body"
# Shows different behavior than compiled mhmail, which suppressed the newline.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with multiple newlines to -body
+start_test "with multiple newlines to -body"
# Shows different behavior than compiled mhmail, which suppressed one
# of the newlines.
cat > "$expected" <<EOF
# check with text and no trailing newline to -body
+start_test "with text and no trailing newline to -body"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check with text and multiple trailing blank lines to -body
+start_test "with text and multiple trailing blank lines to -body"
# Shows different behavior than compiled mhmail, which suppressed one
# of the newlines.
cat > "$expected" <<EOF
# check -resent
+start_test "-resent"
# Verified same behavior as compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
# check -resent -profile, using stdin
+start_test "-resent -profile, using stdin"
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -resent -profile, using -b
+start_test "-resent -profile, using -b"
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check -headerfield.
+start_test "-headerfield."
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
# check multiple -headerfields.
+start_test "multiple -headerfields."
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
From: sender27@example.com
MIME-Version: 1.0
Content-Type: text/plain;charset=utf-8
-Content-Transfer-Encoding: 8bit
+Content-Transfer-Encoding: 7bit
Date:
with added header fields
test_mhmail "$expected" \
"-from sender27@example.com -headerfield MIME-Version:1.0 \
-headerfield Content-Type:text/plain;charset=utf-8 \
--headerfield Content-Transfer-Encoding:8bit" \
+-headerfield Content-Transfer-Encoding:7bit" \
-b 'with added header fields'
[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
# check -attach
+start_test "-attach"
# Not supported by compiled mhmail.
cat > "$expected" <<EOF
EHLO nosuchhost.example.com
[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+finish_test
exit ${failed:-0}