summaryrefslogtreecommitdiffstats
path: root/maildrop/testsuite.in
blob: 81b80a767f7cf5b219358bdacbb1efc7460e12f0 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
#!/bin/sh
#
# Copyright 1998 - 2011 Double Precision, Inc.  See COPYING for
# distribution information.

PWD=`pwd`

unset LC_CTYPE
unset LC_NUMERIC
unset LC_TIME
unset LC_COLLATE
unset LC_MONETARY
unset LC_MESSAGES
unset LC_PAPER
unset LC_NAME
unset LC_ADDRESS
unset LC_TELEPHONE
unset LC_MEASUREMENT
unset LC_IDENTIFICATION
unset LC_ALL

if test "@USE_GDBM@@USE_DB@" != "00" -a -x ../makedat/makedatprog
then

cat <<EOF >testsuite.chk
foo	bar
foo.bar.com	foobar
foobar@foo.bar.com	barfoo
.
EOF
../makedat/makedatprog testsuite.chk testsuite.tmp testsuite.dat

cat <<EOF >testsuite.recipe
if ( gdbmopen("$PWD/testsuite.dat", "R") != 0 )
{
	exit
}

FOO=gdbmfetch("foo")
echo "FOO: \$FOO"

FOO=gdbmfetch("foobar@foo.bar.com", "D")
echo "FOO: \$FOO"
FOO=gdbmfetch("foobaz@foo.bar.com", "D")
echo "FOO: \$FOO"
EOF

chmod go-rw testsuite.recipe
cat <<EOF >testsuite.chk
FOO: bar
FOO: barfoo
FOO: foobar
EOF
./maildrop ./testsuite.recipe </dev/null | diff - testsuite.chk

fi


rm -rf testsuite.maildir
../maildir/maildirmake ./testsuite.maildir

cat <<EOF >testsuite.recipe

FLAGS="S"
to "$PWD/testsuite.maildir"
EOF

chmod go-rw testsuite.recipe

echo "To: testsuite" | ./maildrop ./testsuite.recipe

echo "2,S" >testsuite.chk

ls testsuite.maildir/cur | sed 's/.*://' | diff -U 3 - testsuite.chk

if test "@maildirquota@" = 1
then
	rm -rf testsuite.maildir
	../maildir/maildirmake ./testsuite.maildir

	cat <<EOF >testsuite.recipe

	MAILDIRQUOTA="1C"
	exception {
		cc "$PWD/testsuite.maildir"
		echo "Delivered message one"
		cc "$PWD/testsuite.maildir"
		echo "Delivered message two"
	}
	echo "Done."
	exit
EOF

	chmod go-rw testsuite.recipe
	cat <<EOF >testsuite.chk
Delivered message one
Done.
EOF
	echo "To: testsuite" | ./maildrop ./testsuite.recipe 2>/dev/null \
		| diff - testsuite.chk
fi

cat <<EOF >testsuite.recipe
if ( 2 && 3 )
{
     echo "Yes1"
}

if ( 2 && 0 )
{
     echo "No1"
}

if ( 2 & 1 )
{
     echo "No2"
}

if ( 2 & 3 )
{
     echo "Yes2"
}

a=(4 || 2)

echo "Four: \$a"

a=(4 | 2)

echo "Six: \$a"

a=(5 && 3)

echo "Three: \$a"

a=(5 & 3)

echo "One: \$a"

a=! 5

echo "Zero: \$a"

a= ~5

echo "Minus six: \$a"

EOF

chmod go-rw testsuite.recipe
./maildrop ./testsuite.recipe </dev/null


./reformail -s /bin/bash -c 'cat >testmsg.$FILENO' <<EOF

From message1
From: nobody@example.com
Subject: message1

message1

From message2
From: nobody@example.com
Subject: message2

message2
EOF

./reformail -x subject: <testmsg.000
./reformail -x subject: <testmsg.001
rm testmsg.00[01]

rm -f testcache.dat
./reformail -D 2000 testcache.dat <<EOF
Subject: dummy
Message-ID: <1>

EOF
echo "Not dupe: $?"
./reformail -D 2000 testcache.dat <<EOF
Subject: dummy
Message-ID: <1>

EOF
echo "Not dupe: $?"
rm -f testcache.dat

./reformail -x from: -x subject: <<EOF
From: extract1@example.com
Subject: subject1
Date: today

test
EOF
./reformail -X from: -X subject: <<EOF
From: extract2@example.com
Subject: subject2
Date: today

test
EOF

./reformail -a 'From: me@example.com' -a 'Subject: replacementsubject' <<EOF
From: nobody@example.com

-a test
EOF

./reformail -A 'From: me@example.com' -A 'Subject: replacementsubject' <<EOF
From: nobody@example.com

-A test
EOF

./reformail -c <<EOF
From: nobody@example.com
Subject: catenate
	header test
To: nobody@example.com

test
EOF

./reformail -f0 <<EOF
From testing
Return-Path: old
Subject: remove From_ test

test
EOF
./reformail -f0 <<EOF
Subject: remove From_ test

test
EOF
./reformail -f1 <<EOF
From testing
From: nobody@example.com
Subject: add From_ test

test
EOF
(./reformail -f1 | sed 's/example.com.*/example.com/') <<EOF
From: nobody@example.com
Subject: add From_ test

test
EOF
./reformail -i 'Header1: value1' -i 'Header2: value2' <<EOF
From: nobody@example.com
Subject: -i test
Header1: value1

test
EOF
./reformail -I 'Header1:' -I 'Header2: value2' <<EOF
From: nobody@example.com
Subject: -I test
Header1: value1
Header2: old value2

test
EOF
./reformail -R subject: old-subject: <<EOF
Subject: -R option test
From: nobody@example.com

-R option test
EOF
./reformail -u 'subject:' <<EOF
Subject: -u test, line1
Subject: -u test, line2

Testing -u option
EOF
./reformail -U 'subject:' <<EOF
Subject: -u test, line1
Subject: -u test, line2

Testing -u option
EOF


cat >testmailbot.1 <<EOF
From: =?iso-8859-1?Q?H=F3la!?= <test@example.com>
Return-Path: test2@example.com
Subject: Re: test message (fwd)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1

Original
test
message
EOF

cat >testmailbot.msg <<EOF
Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8

autoreply text
EOF
LANG=en_US.utf-8 ./mailbot -m testmailbot.msg cat <testmailbot.1

cat >testmailbot.1 <<EOF
From: =?iso-8859-1?Q?H=F3la!?= sender <test@xn--80ah.example.com>
To: toaddress@example.com
Cc: ccaddress@example.com
X-Newsgroup: alt.test
Newsgroups: alt.test.1,alt.test.2
Message-Id: <message1@example.com>
Errors-To: test2@example.com
Date: Sun, 22 Nov 2009 11:57:32 -0400
Subject: Re: test message, =?iso-8859-1?Q?H=F3la!?= (fwd)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1

Original
test
message
EOF
LANG=en_US.utf-8 ./mailbot -m testmailbot.msg cat <testmailbot.1
LANG=en_US.utf-8 TZ=EST5EDT ./mailbot -e -m testmailbot.msg \
    -S 'On %d,%nin %C (%N), %F (%f),%nin message %i, %s, writes:' \
    cat <testmailbot.1
LANG=en_US.utf-8 ./mailbot -T replyall -m testmailbot.msg cat <testmailbot.1
LANG=en_US.utf-8 ./mailbot -T replyall -N -m testmailbot.msg cat <testmailbot.1
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

cat >testsuite.recipe <<EOF
if (hasaddr("nobody@example.com"))
{
  echo "Found"
}
else
{
  echo "Not found"
}
exit
EOF

cat >testsuite.msg <<EOF
To: "nobody@host2.example.com" <nobody@example.com>

test
EOF
./maildrop testsuite.recipe <testsuite.msg

cat >testsuite.msg <<EOF
To: "nobody@example.com" <nobody@host2.example.com>

test
EOF
./maildrop testsuite.recipe <testsuite.msg

cat >testsuite.recipe <<EOF
echo getaddr('To: list: "user 1" <user1@example.com>, user2@example.com;')
exit
EOF
./maildrop testsuite.recipe </dev/null

cat >testmailbot.1 <<EOF
Mime-Version: 1.0
From: nobody@example.com
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

H=F3la!
EOF

cat >testmailbot.msg <<EOF
Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8

autoreply text
EOF

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

cat >testmailbot.1 <<EOF
Mime-Version: 1.0
From: nobody@example.com
Content-Type: multipart/alternative; boundary="zzz"

--zzz
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

H=F3la!

--zzz
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<h1>H=F3la!</h1>

--zzz--
EOF

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

cat >testmailbot.1 <<EOF
Mime-Version: 1.0
From: nobody@example.com
Content-Type: multipart/mixed; boundary="zzz"

--zzz
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

H=F3la!

--zzz
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<h1>Attachment h=F3la!</h1>

--zzz--
EOF

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

cat >testmailbot.1 <<EOF
Mime-Version: 1.0
From: nobody@example.com
Subject: HTML message
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<h1>HTML message only</h1>
EOF

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

cat >testmailbot.1 <<EOF
Mime-Version: 1.0
From: nobody@example.com
Subject: multipart/alternative with attachment
Content-Type: multipart/mixed; boundary=zzz

--zzz
Content-Type: multipart/alternative; boundary=yyy


--yyy
Content-Type: text/plain; charset=iso-8859-1

Text version of an HTML message

--yyy
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<h1>HTML message only</h1>

--yyy--

--zzz
Content-Type: text/plain

Text attachment

--zzz--
EOF

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

echo "===================="
LANG=en_US.utf-8 ./mailbot -T forwardatt -F '+++ Forwarded Message +++' -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//'

echo "===================="

LANG=en_US.utf-8 ./mailbot -T reply -m testmailbot.msg cat <<EOF
From: nobody@example.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

Message
> Quote level 1
>> Quote level 2
>
 space
EOF

LANG=en_US.utf-8 ./mailbot -T forward -F '+++ Forwarded Message +++' -m testmailbot.msg cat <<EOF
From: nobody@example.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

Message
> Quote level 1
>> Quote level 2
>
 space
EOF

cat >testmailbot.1 <<EOF
From: test@example.com
Return-Path: test2@example.com
Subject: Test message
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1

Original
test
message
EOF

cat >testmailbot.msg <<EOF
Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8
Content-Transfer-Encoding: 8bit

DSN message text
EOF

LANG=en_US.utf-8 ./mailbot -M nobody@example.com -N -m testmailbot.msg cat <testmailbot.1 | sed 's/=_.*//;s/Arrival-Date:.*/Arrival-Date:/'

LANG=en_US.utf-8 ./mailbot -T replyfeedback -R abuse -n -N -m testmailbot.msg \
    --feedback-source-ip 127.0.0.1 \
    --feedback-incidents 2 \
    <testmailbot.1 | sed 's/=_.*//;s/Arrival-Date:.*/Arrival-Date:/;s/User-Agent:.*//'

LANG=en_US.utf-8 ./mailbot -T feedback -R abuse -n -N -m testmailbot.msg \
    --feedback-source-ip 127.0.0.1 \
    --feedback-incidents 2 \
    <testmailbot.1 | sed 's/=_.*//;s/Arrival-Date:.*/Arrival-Date:/;s/User-Agent:.*//'

rm -f testsuite.recipe
rm -f testsuite.msg
rm -f testsuite.chk
rm -f testmailbot.msg
rm -f testmailbot.1
rm -f testsuite.dat
rm -rf testsuite.maildir