summaryrefslogtreecommitdiff
path: root/test/tests/dsn
blob: 290d21de08815b5b73af7dbeb8d1b55d5b3b653a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
. functions

msgid=message.id.$$.$RANDOM@f.q.d.n
dsn() {
	$builddir/src/nullmailer-dsn "$@" << EOF
sender@example.com
recip1@example.net
recip2@example.org

Subject: test message
Message-Id: <$msgid>
From: <sender@example.com>
To: <recip1@example.net>
Cc: <recip2@example.org>

This is a test.
line 2
line 3
line 4
EOF
}

fn=$tmpdir/dsn-tmp
dsn 5.2.9 | splitblank $fn

echo -n Testing envelope: sender
not test -x $fn.1
echo -n , recipient
grep -qx sender@example.com $fn.2
echo -n , end
test $( wc -l < $fn.2 ) = 1
echo

date='..., [ 0-9][0-9] ... [0-9]{4} [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]{4}'
echo -n Testing header: from
grep -qx 'From: Message Delivery Subsystem <MAILER-DAEMON@f.q.d.n>' $fn.3
echo -n , to
grep -qx 'To: <sender@example.com>' $fn.3
echo -n , subject
grep -qx 'Subject: Returned mail: Could not send message' $fn.3
echo -n , date
egrep -q "^Date: $date$" $fn.3
echo -n , message-id
grep -q '^Message-Id: <.*.nullmailer@f.q.d.n>$' $fn.3
echo -n , mime
grep -qx 'MIME-Version: 1.0' $fn.3
echo -n , content-type
grep -q '^Content-Type: multipart/report; report-type=delivery-status;' $fn.3
echo

echo -n Testing report header: reporting-mta
grep -qx "Reporting-MTA: x-local-hostname; f.q.d.n" $fn.8
echo -n , date
egrep -q "^Arrival-Date: $date$" $fn.8
echo

echo -n Testing recipient report 1: final-recipient
grep -qx 'Final-Recipient: rfc822; recip1@example.net' $fn.9
echo -n , action
grep -qx 'Action: failed' $fn.9
echo -n , status
grep -qx 'Status: 5.2.9' $fn.9
echo -n , date
egrep -q "^Last-Attempt-Date: $date$" $fn.9
echo

echo -n Testing recipient report 2: final-recipient
grep -qx 'Final-Recipient: rfc822; recip2@example.org' $fn.10
echo -n , action
grep -qx 'Action: failed' $fn.10
echo -n , status
grep -qx 'Status: 5.2.9' $fn.10
echo -n , date
egrep -q "^Last-Attempt-Date: $date$" $fn.10
echo

echo Testing quoted message pre-header
grep -qx 'Content-Type: message/rfc822' $fn.11

echo Testing quoted message header
grep -qx "Message-Id: <$msgid>" $fn.12

echo Testing quoted message body
not grep -qx "This is a test." $fn.13

echo Testing fixed bounce address
echo admin@example.com > $SYSCONFDIR/bounceto
dsn 5.2.9 | splitblank $fn
grep -qx admin@example.com $fn.2

echo -n Testing max-lines: 0
dsn --max-lines=0 5.2.9 | not grep -qx "This is a test."
echo -n , 1
dsn --max-lines=1 5.2.9 | grep -qx "This is a test."
dsn --max-lines=1 5.2.9 | not grep -qx "line 2"
echo -n , 2
dsn --max-lines=2 5.2.9 | grep -qx "line 2"
dsn --max-lines=2 5.2.9 | not grep -qx "line 3"
echo -n , bouncelines=1
echo 1 > $SYSCONFDIR/bouncelines
dsn 5.2.9 | grep -qx "This is a test."
dsn 5.2.9 | not grep -qx "line 2"
echo -n , override
dsn --max-lines=2 5.2.9 | grep -qx "line 2"
dsn --max-lines=2 5.2.9 | not grep -qx "line 3"
echo

rm -f $fn.* $SYSCONFDIR/bounceto $SYSCONFDIR/bouncelines