2 ######################################################
4 # Test aliases all the way through post
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname "$0"`/../..
12 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
15 . "${srcdir}/test/post/test-post-common.sh"
17 # Note that the last address in the blind list does not end with a
19 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
20 blind_list: Blind List: one, two, three
21 named.list; one@example.com, two@example.com
24 three: three@example.com
27 #### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
28 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
29 cp "${MHMTSCONF}" "$mts_fakesendmail"
30 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
31 MHMTSCONF="$mts_fakesendmail"
33 # $1: -mts switch selection
37 if [ "$1" = 'sendmail/smtp' ]; then
38 send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/smtp
40 # fakesendmail drops the message and any cc's into this mbox.
41 mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
42 inc -silent -file "$mbox"
43 rm -f "$mbox" "$mbox.map"
45 # It's hard to calculate the exact Date: header post is going to
46 # use, so we'll just use sed to remove the actual date so we can easily
47 # compare it against our "correct" output.
48 sed -e 's/^Date:.*/Date:/' "`mhpath cur`" >"${testname}.actual"
50 check "${testname}.actual" "$2"
52 if [ "`mhpath cur`" != "`mhpath last`" ]; then
53 folder next >/dev/null
54 arith_eval $n + 1; n=$arith_val
57 elif [ "$1" = 'sendmail/pipe' ]; then
59 send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/pipe \
60 >"${testname}.actual" 2>&1
62 printf '%s: sendmail/pipe should have failed but didn'"'"'t\n' "$0"
65 check "${testname}.actual" "$2"
69 printf '%s: invalid -mts switch selection\n' "$0"
76 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
77 From: Mr Nobody <nobody@example.com>
79 Subject: blind list test
81 This is test of a blind list.
83 cp -p "${MH_TEST_DIR}/Mail/draft" "${MH_TEST_DIR}/Mail/draft2"
85 cat >"${testname}.expected" <<EOF
86 From: Mr Nobody <nobody@example.com>
88 Subject: blind list test
91 This is test of a blind list.
94 test_alias sendmail/smtp "${testname}.expected"
96 # Make sure the addresses were expanded correctly.
97 mv "${MH_TEST_DIR}/Mail/draft2" "${MH_TEST_DIR}/Mail/draft"
99 cat > "${testname}.expected" <<EOF
100 EHLO nosuchhost.example.com
101 MAIL FROM:<nobody@example.com>
102 RCPT TO:<one@example.com>
103 RCPT TO:<two@example.com>
104 RCPT TO:<three@example.com>
106 From: Mr Nobody <nobody@example.com>
108 Subject: blind list test
111 This is test of a blind list.
116 test_post "${testname}.actual" "${testname}.expected" \
117 "-alias ${MH_TEST_DIR}/Mail/aliases"
119 # check named list (alias followed by ;)
120 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
121 From: Mr Nobody <nobody@example.com>
123 Subject: named list test
125 This is test of a named list.
128 cat >"${testname}.expected" <<EOF
129 From: Mr Nobody <nobody@example.com>
130 To: "named.list" <one@example.com>, "named.list" <two@example.com>
131 Subject: named list test
134 This is test of a named list.
137 test_alias sendmail/smtp "${testname}.expected"
139 # check blind list with -mts sendmail/pipe, which should fail
140 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
141 From: Mr Nobody <nobody@example.com>
143 Subject: blind list test
145 This is test of a blind list.
148 cat >"${testname}.expected" <<EOF
149 post: blind lists not compatible with sendmail/pipe
150 send: message not delivered to anyone
153 test_alias sendmail/pipe "${testname}.expected"