]> diplodocus.org Git - nmh/blob - test/post/test-post-envelope
Alter HasSuffixC()'s char * to be const.
[nmh] / test / post / test-post-envelope
1 #!/bin/sh
2 #
3 # Test the setting of the envelope-from address for SMTP
4 #
5 # Note here we use multiple From: addresses for some tests so we pick up
6 # some cases skipped in other tests.
7 #
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname "$0"`/../..
13 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "${srcdir}/test/post/test-post-common.sh"
17
18 #
19 # Sender
20 #
21
22 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
23 From: Mr Nobody One <nobody1@example.com>,
24 Mr Nobody Two <nobody2@example.com>
25 Sender: Mr Nobody Three <nobody3@example.com>
26 To: Somebody Else <somebody@example.com>
27 Subject: Sender test
28
29 This is a test of the Sender header.
30 EOF
31
32 cat > "${testname}.0.expected" <<EOF
33 EHLO nosuchhost.example.com
34 MAIL FROM:<nobody3@example.com>
35 RCPT TO:<somebody@example.com>
36 DATA
37 From: Mr Nobody One <nobody1@example.com>,
38 Mr Nobody Two <nobody2@example.com>
39 Sender: Mr Nobody Three <nobody3@example.com>
40 To: Somebody Else <somebody@example.com>
41 Subject: Sender test
42 MIME-Version: 1.0
43 Content-Type: text/plain; charset="us-ascii"
44 Date:
45
46 This is a test of the Sender header.
47 .
48 QUIT
49 EOF
50
51 test_post "${testname}.0.actual" "${testname}.0.expected"
52
53 #
54 # Check to see if Envelope-From overrides Sender
55 #
56
57 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
58 From: Mr Nobody One <nobody1@example.com>,
59 Mr Nobody Two <nobody2@example.com>
60 Sender: Mr Nobody Three <nobody3@example.com>
61 Envelope-From: Mr Nobody Four <nobody4@example.com>
62 To: Somebody Else <somebody@example.com>
63 Subject: Envelope-From test
64
65 This is a test of the Envelope-From header.
66 EOF
67
68 cat > "${testname}.1.expected" <<EOF
69 EHLO nosuchhost.example.com
70 MAIL FROM:<nobody4@example.com>
71 RCPT TO:<somebody@example.com>
72 DATA
73 From: Mr Nobody One <nobody1@example.com>,
74 Mr Nobody Two <nobody2@example.com>
75 Sender: Mr Nobody Three <nobody3@example.com>
76 To: Somebody Else <somebody@example.com>
77 Subject: Envelope-From test
78 MIME-Version: 1.0
79 Content-Type: text/plain; charset="us-ascii"
80 Date:
81
82 This is a test of the Envelope-From header.
83 .
84 QUIT
85 EOF
86
87 test_post "${testname}.1.actual" "${testname}.1.expected"
88
89 #
90 # See if Envelope-From will generate a Sender: header with multiple From:
91 # addresses
92 #
93
94 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
95 From: Mr Nobody One <nobody1@example.com>,
96 Mr Nobody Two <nobody2@example.com>
97 Envelope-From: Mr Nobody Four <nobody4@example.com>
98 To: Somebody Else <somebody@example.com>
99 Subject: Envelope-From and Sender test
100
101 This is a test of the Envelope-From and Sender headers.
102 EOF
103
104 cat > "${testname}.2.expected" <<EOF
105 EHLO nosuchhost.example.com
106 MAIL FROM:<nobody4@example.com>
107 RCPT TO:<somebody@example.com>
108 DATA
109 From: Mr Nobody One <nobody1@example.com>,
110 Mr Nobody Two <nobody2@example.com>
111 To: Somebody Else <somebody@example.com>
112 Subject: Envelope-From and Sender test
113 MIME-Version: 1.0
114 Content-Type: text/plain; charset="us-ascii"
115 Date:
116 Sender: nobody4@example.com
117
118 This is a test of the Envelope-From and Sender headers.
119 .
120 QUIT
121 EOF
122
123 test_post "${testname}.2.actual" "${testname}.2.expected"
124
125 #
126 # And make sure we do NOT get a Sender with only one From:
127 #
128
129 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
130 From: Mr Nobody One <nobody1@example.com>
131 Envelope-From: Mr Nobody Five <nobody5@example.com>
132 To: Somebody Else <somebody@example.com>
133 Subject: Solo Envelope-From test
134
135 This is a solo test of the Envelope-From header.
136 EOF
137
138 cat > "${testname}.3.expected" <<EOF
139 EHLO nosuchhost.example.com
140 MAIL FROM:<nobody5@example.com>
141 RCPT TO:<somebody@example.com>
142 DATA
143 From: Mr Nobody One <nobody1@example.com>
144 To: Somebody Else <somebody@example.com>
145 Subject: Solo Envelope-From test
146 MIME-Version: 1.0
147 Content-Type: text/plain; charset="us-ascii"
148 Date:
149
150 This is a solo test of the Envelope-From header.
151 .
152 QUIT
153 EOF
154
155 test_post "${testname}.3.actual" "${testname}.3.expected"
156
157 #
158 # Make sure blank Envelope-From does what we expect it to
159 #
160
161 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
162 From: Mr Nobody One <nobody1@example.com>
163 Envelope-From:
164 To: Somebody Else <somebody@example.com>
165 Subject: Blank Envelope-From test
166
167 This is a blank test of the Envelope-From header.
168 EOF
169
170 cat > "${testname}.4.expected" <<EOF
171 EHLO nosuchhost.example.com
172 MAIL FROM:<>
173 RCPT TO:<somebody@example.com>
174 DATA
175 From: Mr Nobody One <nobody1@example.com>
176 To: Somebody Else <somebody@example.com>
177 Subject: Blank Envelope-From test
178 MIME-Version: 1.0
179 Content-Type: text/plain; charset="us-ascii"
180 Date:
181
182 This is a blank test of the Envelope-From header.
183 .
184 QUIT
185 EOF
186
187 test_post "${testname}.4.actual" "${testname}.4.expected"
188
189 exit ${failed:-0}