]>
diplodocus.org Git - nmh/blob - test/post/test-post-aliases
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
25 four: Mister Four <four@example.com>
28 #### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
29 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
30 cp "${MHMTSCONF}" "$mts_fakesendmail"
31 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
32 MHMTSCONF
="$mts_fakesendmail"
34 # $1: -mts switch selection
38 if [ "$1" = 'sendmail/smtp' ]; then
39 run_prog send
-draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail
/smtp
41 # fakesendmail drops the message and any cc's into this mbox.
42 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
43 inc
-silent -file "$mbox"
46 # It's hard to calculate the exact Date: header post is going to
47 # use, so we'll just use sed to remove the actual date so we can easily
48 # compare it against our "correct" output.
49 sed -e 's/^Date:.*/Date:/' "`mhpath cur`" >"${testname}.actual"
51 check
"${testname}.actual" "$2"
53 if [ "`mhpath cur`" != "`mhpath last`" ]; then
54 folder next
>/dev
/null
55 arith_eval
$n + 1; n
=$arith_val
58 elif [ "$1" = 'sendmail/pipe' ]; then
60 run_prog send
-draft -alias "${MH_TEST_DIR}/Mail/aliases" \
61 -mts sendmail
/pipe
>"${testname}.actual" 2>&1
63 printf '%s: sendmail/pipe should have failed but didn'"'"'t\n' "$0"
66 check
"${testname}.actual" "$2"
70 printf '%s: invalid -mts switch selection\n' "$0"
77 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
78 From: Mr Nobody <nobody@example.com>
80 Subject: blind list test
82 This is test of a blind list.
84 cp -p "${MH_TEST_DIR}/Mail/draft" "${MH_TEST_DIR}/Mail/draft2"
86 cat >"${testname}.expected" <<EOF
87 From: Mr Nobody <nobody@example.com>
89 Subject: blind list test
91 Content-Type: text/plain; charset="us-ascii"
94 This is test of a blind list.
97 test_alias sendmail
/smtp
"${testname}.expected"
99 # Make sure the addresses were expanded correctly.
100 mv "${MH_TEST_DIR}/Mail/draft2" "${MH_TEST_DIR}/Mail/draft"
102 cat > "${testname}.expected" <<EOF
103 EHLO nosuchhost.example.com
104 MAIL FROM:<nobody@example.com>
105 RCPT TO:<one@example.com>
106 RCPT TO:<two@example.com>
107 RCPT TO:<three@example.com>
109 From: Mr Nobody <nobody@example.com>
111 Subject: blind list test
113 Content-Type: text/plain; charset="us-ascii"
116 This is test of a blind list.
121 test_post
"${testname}.actual" "${testname}.expected" \
122 "-alias ${MH_TEST_DIR}/Mail/aliases"
124 # check named list (alias followed by ;)
125 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
126 From: Mr Nobody <nobody@example.com>
128 Subject: named list test
130 This is test of a named list.
133 cat >"${testname}.expected" <<EOF
134 From: Mr Nobody <nobody@example.com>
135 To: "named.list" <one@example.com>, "named.list" <two@example.com>
136 Subject: named list test
138 Content-Type: text/plain; charset="us-ascii"
141 This is test of a named list.
144 test_alias sendmail
/smtp
"${testname}.expected"
146 # check blind list with -mts sendmail/pipe, which should fail
147 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
148 From: Mr Nobody <nobody@example.com>
150 Subject: blind list test
152 This is test of a blind list.
155 cat >"${testname}.expected" <<EOF
156 post: blind lists not compatible with sendmail/pipe
157 send: message not delivered to anyone
160 test_alias sendmail
/pipe
"${testname}.expected"
162 # check that alias expansion happens in the From: line when doing a bcc
163 cat >"${MH_TEST_DIR}/Mail/draft" <<EOF
167 Subject: from bcc expansion test
169 This is test of from line expansion for a bcc.
172 cat >"${testname}.expected" <<EOF
173 EHLO nosuchhost.example.com
174 MAIL FROM:<four@example.com>
175 RCPT TO:<one@example.com>
176 RCPT TO:<two@example.com>
178 MAIL FROM:<four@example.com>
179 RCPT TO:<one@example.com>
181 From: Mister Four <four@example.com>
183 Subject: from bcc expansion test
185 Content-Type: text/plain; charset="us-ascii"
188 This is test of from line expansion for a bcc.
191 MAIL FROM:<four@example.com>
192 RCPT TO:<two@example.com>
194 From: Mister Four <four@example.com>
196 Subject: from bcc expansion test
199 ------- Blind-Carbon-Copy
201 From: Mister Four <four@example.com>
203 Subject: from bcc expansion test
205 Content-Type: text/plain; charset="us-ascii"
208 This is test of from line expansion for a bcc.
210 ------- End of Blind-Carbon-Copy
215 test_post
"${testname}.actual" "${testname}.expected" \
216 "-alias ${MH_TEST_DIR}/Mail/aliases"