]> diplodocus.org Git - nmh/blob - test/send/test-sendfrom
lock_file.c: close(2) file descriptor on failure, avoiding leak.
[nmh] / test / send / test-sendfrom
1 #!/bin/sh
2 ######################################################
3 #
4 # Test sendfrom
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
18 # TEST
19 start_test 'sendfrom, using -snoop'
20
21 #### Set up profile to use sendfrom by adding a sendfrom-addr. This one adds
22 #### -snoop to the send switches. The output from snoop is constant, and so
23 #### is easily checked below.
24 cat >> "$MH" <<EOF
25 sendfrom-nobody@example.com: -snoop
26 EOF
27
28 cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
29 From: Mr Nobody <nobody@example.com>
30 To: Somebody Else <somebody@example.com>
31 Subject: Test
32
33 This is a test.
34 EOF
35
36 cat > "${testname}.expected" <<EOF
37 EHLO nosuchhost.example.com
38 MAIL FROM:<nobody@example.com>
39 RCPT TO:<somebody@example.com>
40 DATA
41 From: Mr Nobody <nobody@example.com>
42 To: Somebody Else <somebody@example.com>
43 Subject: Test
44 MIME-Version: 1.0
45 Content-Type: text/plain; charset="us-ascii"
46 Date:
47
48 This is a test.
49 .
50 QUIT
51 EOF
52
53 cat > "${testname}.post-expected" <<EOF
54 Trying to connect to "127.0.0.1" ...
55 Connecting to 127.0.0.1:${localport}...
56 <= 220 Not really an ESMTP server
57 => EHLO nosuchhost.example.com
58 <= 250-ready
59 <= 250 I'll buy that for a dollar!
60 => MAIL FROM:<nobody@example.com>
61 <= 250 I'll buy that for a dollar!
62 => RCPT TO:<somebody@example.com>
63 <= 250 I'll buy that for a dollar!
64 => DATA
65 <= 354 Go ahead
66 => .
67 <= 250 Thanks for the info!
68 => QUIT
69 <= 221 Later alligator!
70 EOF
71
72 test_post "${testname}.actual" "${testname}.expected" \
73 2> ${testname}.post
74
75 check "${testname}.post-expected" "${testname}.post"
76
77
78 finish_test
79
80 exit ${failed:-0}