8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 . "${MH_OBJ_DIR}/test/common.sh"
16 testname="${MH_TEST_DIR}/$$"
19 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
20 From: Mr Nobody <nobody@example.com>
21 To: Somebody Else <somebody@example.com>
27 cat > "${testname}.expected" <<EOF
28 EHLO nosuchhost.example.com
29 MAIL FROM:<nobody@example.com>
30 RCPT TO:<somebody@example.com>
32 From: Mr Nobody <nobody@example.com>
33 To: Somebody Else <somebody@example.com>
42 # check invalid -messageid selection
43 run_test "send -draft -messageid invalid" \
44 "post: unsupported messageid \"invalid\"
45 send: message not delivered to anyone"
47 #### Rely on sendmail/pipe below to override default mts.
48 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
49 cp "${MHMTSCONF}" "$mts_fakesendmail"
50 printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail"
51 MHMTSCONF="$mts_fakesendmail"
53 # $1: -messageid switch selection
54 # arguments: expected output(s)
58 send -draft -mts sendmail/pipe -msgid -messageid "$msgid_style"
61 # fakesendmail drops the message and any cc's into this mbox.
62 mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
63 inc -silent -file "$mbox"
64 rm -f "$mbox" "$mbox.map"
67 for expected in "$@"; do
69 # Verify that Message-ID is of the right form. We'll see how
70 # portable these grep regular expressions are.
71 case "$msgid_style" in
73 # e.g., Message-ID: <5348.1342884222@localhost.localdomain>
74 id='^Message-ID: <[0-9]\{1,\}\.[0-9]\{1,\}@'
77 # e.g., Message-ID: <5364-1342884222.165897@ldYM.FXwU.bBqK>
78 id='^Message-ID: <[0-9]\{1,\}-[0-9]\{1,\}\.[0-9]\{6,6\}@[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}'
80 *) printf "$0: unexpected messageid: $msgid_style"; exit 1;;
83 if grep "$id" "$cur" >/dev/null; then
86 mv "$cur" "${testname}.actual"
87 printf "$0: unexpected "$msgid_style" Message-ID format, \
88 see ${testname}.actual\n"
93 # It's hard to calculate the exact Date: header post is going to
94 # use, so we'll just use sed to remove the actual date so we can easily
95 # compare it against our "correct" output. And same for
98 sed -e 's/^Date:.*/Date:/' \
99 -e 's/^Message-ID:.*/Message-ID:/' \
100 "$cur" > "${testname}.actual$n"
102 check "${testname}.actual$n" "$expected"
104 if [ "$cur" != "`mhpath last`" ]; then
105 folder next >/dev/null
106 arith_eval $n + 1; n=$arith_val
111 # check -messageid localname (the default)
112 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
113 From: Mr Nobody <nobody@example.com>
114 To: Somebody Else <somebody@example.com>
121 cat > "${testname}.expected" <<EOF
122 From: Mr Nobody <nobody@example.com>
123 To: Somebody Else <somebody@example.com>
132 test_messageid localname "${testname}.expected"
134 # check -messageid random
135 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
136 From: Mr Nobody <nobody@example.com>
137 To: Somebody Else <somebody@example.com>
144 cat > "${testname}.expected" <<EOF
145 From: Mr Nobody <nobody@example.com>
146 To: Somebody Else <somebody@example.com>
155 test_messageid random "${testname}.expected"