Removed -m from sendmail invocation with sendmail/pipe. Modern
[mmh] / test / post / test-sendmail-pipe
1 #!/bin/sh
2 #
3 # Test the basic behavior of post when configured with sendmail/pipe
4 # delivery method.
5 #
6
7 set -e
8
9 if test -z "${MH_OBJ_DIR}"; then
10     srcdir=`dirname "$0"`/../..
11     MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
12 fi
13
14 . "${MH_OBJ_DIR}/test/common.sh"
15
16 setup_test
17 testname="${MH_TEST_DIR}/$$"
18
19 #### Force test of sendmail/pipe regardless of configuration.
20 mts_pipe="${MHMTSCONF}-pipe"
21 sed -e 's/mts: *.*/mts: sendmail\/pipe/' "${MHMTSCONF}" >"$mts_pipe"
22 printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_pipe"
23 MHMTSCONF="$mts_pipe"
24
25 test_sendmail_pipe ()
26 {
27   send -draft
28
29   # fakesendmail drops the message and any cc's into this mbox.
30   mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
31   inc -silent -file "$mbox"
32   rm -f "$mbox" "$mbox.map"
33
34   n=1
35   for expected in "$@"; do
36     #
37     # It's hard to calculate the exact Date: header post is going to
38     # use, so we'll just use sed to remove the actual date so we can easily
39     # compare it against our "correct" output.
40     #
41     sed -e 's/^Date:.*/Date:/' "`mhpath cur`" > "${testname}.actual$n"
42
43     check "${testname}.actual$n" "$expected"
44
45     if [ "`mhpath cur`" != "`mhpath last`" ]; then
46       folder next >/dev/null
47       arith_eval $n + 1; n=$arith_val
48     fi
49   done
50 }
51
52 #
53 # Basic test - Simple message, single user, single recipient.  Dots
54 # are not stuffed because sendmail/pipe causes sendmail to be invoked
55 # with -i.
56 #
57 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
58 From: Mr Nobody <nobody@example.com>
59 To: Somebody Else <somebody@example.com>
60 Subject: Test
61
62 This is a test
63 .
64 EOF
65
66 cat > "${testname}.expected" <<EOF
67 From: Mr Nobody <nobody@example.com>
68 To: Somebody Else <somebody@example.com>
69 Subject: Test
70 Date:
71
72 This is a test
73 .
74 EOF
75
76 test_sendmail_pipe "${testname}.expected"
77
78
79 # check Bcc
80 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
81 From: Mr Nobody <nobody@example.com>
82 To: Somebody Else <somebody@example.com>
83 Bcc: Silent Partner <bcc@example.com>
84 Subject: Test
85
86 This is a test
87 .
88 EOF
89
90 cat > "${testname}.expected1" <<EOF
91 From: Mr Nobody <nobody@example.com>
92 To: Somebody Else <somebody@example.com>
93 Subject: Test
94 Date:
95
96 This is a test
97 .
98 EOF
99
100 cat > "${testname}.expected2" <<EOF
101 Date:
102 Subject: Test
103
104 ------- Blind-Carbon-Copy
105
106 From: Mr Nobody <nobody@example.com>
107 To: Somebody Else <somebody@example.com>
108 Subject: Test
109 Date:
110
111 This is a test
112 .
113
114 ------- End of Blind-Carbon-Copy
115 EOF
116
117 test_sendmail_pipe "${testname}.expected1" "${testname}.expected2"
118
119
120 rm -f ${MHMTSCONF}
121
122 exit ${failed:-0}