Debian Codegraph @

test/post/test-post-envelope

raw
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 <[email protected]>,
24 Mr Nobody Two <[email protected]>
25 Sender: Mr Nobody Three <[email protected]>
26 To: Somebody Else <[email protected]>
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:<[email protected]>
35 RCPT TO:<[email protected]>
36 DATA
37 From: Mr Nobody One <[email protected]>,
38 Mr Nobody Two <[email protected]>
39 Sender: Mr Nobody Three <[email protected]>
40 To: Somebody Else <[email protected]>
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 <[email protected]>,
59 Mr Nobody Two <[email protected]>
60 Sender: Mr Nobody Three <[email protected]>
61 Envelope-From: Mr Nobody Four <[email protected]>
62 To: Somebody Else <[email protected]>
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:<[email protected]>
71 RCPT TO:<[email protected]>
72 DATA
73 From: Mr Nobody One <[email protected]>,
74 Mr Nobody Two <[email protected]>
75 Sender: Mr Nobody Three <[email protected]>
76 To: Somebody Else <[email protected]>
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 <[email protected]>,
96 Mr Nobody Two <[email protected]>
97 Envelope-From: Mr Nobody Four <[email protected]>
98 To: Somebody Else <[email protected]>
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:<[email protected]>
107 RCPT TO:<[email protected]>
108 DATA
109 From: Mr Nobody One <[email protected]>,
110 Mr Nobody Two <[email protected]>
111 To: Somebody Else <[email protected]>
112 Subject: Envelope-From and Sender test
113 MIME-Version: 1.0
114 Content-Type: text/plain; charset="us-ascii"
115 Date:
116 Sender: [email protected]
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 <[email protected]>
131 Envelope-From: Mr Nobody Five <[email protected]>
132 To: Somebody Else <[email protected]>
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:<[email protected]>
141 RCPT TO:<[email protected]>
142 DATA
143 From: Mr Nobody One <[email protected]>
144 To: Somebody Else <[email protected]>
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 <[email protected]>
163 Envelope-From:
164 To: Somebody Else <[email protected]>
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:<[email protected]>
174 DATA
175 From: Mr Nobody One <[email protected]>
176 To: Somebody Else <[email protected]>
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}