]> diplodocus.org Git - nmh/blob - test/post/test-rfc6531
Reverted commit 9a4b4a3d3b27fe4a7ff6d0b8724ce1c06b5917eb.
[nmh] / test / post / test-rfc6531
1 #!/bin/sh
2 ######################################################
3 #
4 # Test SMTPUTF8 (RFC 6531) support.
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "${srcdir}/test/post/test-post-common.sh"
16
17 setup_test
18 mhl="${MH_LIBEXEC_DIR}/mhl"
19 SMTPUTF8=1; export SMTPUTF8
20
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
23
24 #### Enable EAI in mhbuild, via the profile.
25 sed "s%^\(mhbuild: .*\)%\1 -headerencoding utf-8%" "$MH" >"$MH.new"
26 mv -f "$MH.new" "$MH"
27
28 # check SMTPUTF8 basic
29 start_test 'SMTPUTF8 basic'
30
31 cat > "${testname}.expected" <<EOF
32 EHLO nosuchhost.example.com
33 MAIL FROM:<senderø@example.com> BODY=8BITMIME SMTPUTF8
34 RCPT TO:<recipientæ@example.com>
35 DATA
36 From: senderø@example.com
37 To: recipientæ@example.com
38 Subject: Blåbærsyltetøy
39 MIME-Version: 1.0
40 Content-Type: text/plain; charset="UTF-8"
41 Content-Transfer-Encoding: 8bit
42 Date:
43
44 Blåbærsyltetøy er veldig godt. Jeg liker blåbærsyltetøy.
45 Jøran.
46
47 Text source:
48 Arnt Gulbrandsen and Jiankang Yao, "Email Address Internationalization",
49 Computing Edge 1:6, June 2015,
50 http://www.computer.org/cms/computing-edge/ce-jun15-final.pdf, p. 50.
51 .
52 QUIT
53 EOF
54
55 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
56 From: senderø@example.com
57 To: recipientæ@example.com
58 Subject: Blåbærsyltetøy
59 --------
60 Blåbærsyltetøy er veldig godt. Jeg liker blåbærsyltetøy.
61 Jøran.
62
63 Text source:
64 Arnt Gulbrandsen and Jiankang Yao, "Email Address Internationalization",
65 Computing Edge 1:6, June 2015,
66 http://www.computer.org/cms/computing-edge/ce-jun15-final.pdf, p. 50.
67 EOF
68
69 test_post "${testname}.actual" "${testname}.expected"
70
71
72 # check SMTPUTF8 without 8-bit body
73 start_test '8-bit headers with ASCII body'
74
75 cat > "${testname}.expected" <<EOF
76 EHLO nosuchhost.example.com
77 MAIL FROM:<senderø@example.com> BODY=8BITMIME SMTPUTF8
78 RCPT TO:<recipientæ@example.com>
79 DATA
80 From: senderø@example.com
81 To: recipientæ@example.com
82 Subject: Blåbærsyltetøy
83 MIME-Version: 1.0
84 Content-Type: text/plain; charset="UTF-8"
85 Content-Transfer-Encoding: 8bit
86 Date:
87
88 This is a test.
89 .
90 QUIT
91 EOF
92
93 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
94 From: senderø@example.com
95 To: recipientæ@example.com
96 Subject: Blåbærsyltetøy
97 --------
98 This is a test.
99 EOF
100
101 test_post "${testname}.actual" "${testname}.expected"
102
103
104 # check with smtp server that doesn't support SMTPUTF8
105 start_test "smtp server doesn't support SMTPUTF8"
106 unset SMTPUTF8
107 cat > "${testname}.expected" <<EOF
108 EHLO nosuchhost.example.com
109 RSET
110 QUIT
111 EOF
112 cat > "${testname}.expected.err" <<EOF
113 post: SMTP server does not support SMTPUTF8, not sending.
114 Rebuild message with 7-bit headers, WITHOUT -headerencoding utf-8.
115 post: problem initializing server; [BHST] ready; I'll buy that for a dollar!
116 send: message not delivered to anyone
117 EOF
118 mv -f "${MH_TEST_DIR}/Mail/,draft" "${MH_TEST_DIR}/Mail/draft"
119
120 set +e
121 test_post "${testname}.actual" "${testname}.expected" 2>"${testname}.err"
122 set -e
123 check "${testname}.err" "${testname}.expected.err"
124
125
126 finish_test
127 exit $failed