xref: /PHP-8.0/ext/imap/tests/bug40854.phpt (revision 6bb94eac)
1--TEST--
2Bug #40854 (imap_mail_compose() creates an invalid terminator for multipart e-mails)
3--SKIPIF--
4<?php
5        if (!extension_loaded("imap")) {
6                die("skip imap extension not available");
7        }
8?>
9--FILE--
10<?php
11$envelope["from"]= "joe@example.com";
12$envelope["to"]  = "foo@example.com";
13$envelope["cc"]  = "bar@example.com";
14
15$part1["type"] = TYPEMULTIPART;
16$part1["subtype"] = "mixed";
17
18$part2["type"] = TYPEAPPLICATION;
19$part2["encoding"] = ENCBINARY;
20$part2["subtype"] = "octet-stream";
21$part2["description"] = 'a.txt';
22$part2["contents.data"] = '';
23
24$part3["type"] = TYPETEXT;
25$part3["subtype"] = "plain";
26$part3["description"] = "description3";
27$part3["contents.data"] = "contents.data3\n\n\n\t";
28
29$body[1] = $part1;
30$body[2] = $part2;
31$body[3] = $part3;
32
33echo imap_mail_compose($envelope, $body);
34?>
35--EXPECTF--
36From: joe@example.com
37To: foo@example.com
38cc: bar@example.com
39MIME-Version: 1.0
40Content-Type: MULTIPART/mixed; BOUNDARY="%s"
41
42--%s
43Content-Type: APPLICATION/octet-stream
44Content-Transfer-Encoding: BASE64
45Content-Description: a.txt
46
47
48
49--%s
50Content-Type: TEXT/plain; CHARSET=US-ASCII
51Content-Description: description3
52
53contents.data3
54
55
56
57--%s--
58