xref: /php-src/ext/standard/tests/mail/bug72964.phpt (revision f62f6a6d)
1--TEST--
2Bug #72964 (White space not unfolded for CC/Bcc headers)
3--SKIPIF--
4<?php
5if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
6require_once __DIR__.'/mail_windows_skipif.inc';
7?>
8--INI--
9SMTP=localhost
10smtp_port=25
11sendmail_from=from@example.com
12--FILE--
13<?php
14
15require_once __DIR__.'/mail_util.inc';
16$users = MailBox::USERS;
17
18$to = $users[0];
19$from = ini_get('sendmail_from');
20$cc = ['cc1' => $users[0], 'cc2' => $users[1]];
21$bcc = ['bcc1' => $users[2], 'bcc2' => $users[3]];
22$subject = 'mail_bug72964';
23$message = 'hello';
24$headers = "From: {$from}\r\n"
25    . "Cc: {$cc['cc1']},\r\n\t{$cc['cc2']}\r\n"
26    . "Bcc: {$bcc['bcc1']},\r\n {$bcc['bcc2']}\r\n";
27
28$res = mail($to, $subject, $message, $headers);
29
30if ($res !== true) {
31    die("Unable to send the email.\n");
32}
33
34echo "Email sent.\n";
35
36foreach ([['to' => $to], $cc, $bcc] as $mailAddresses) {
37    foreach ($mailAddresses as $recipient => $mailAddress) {
38        $mailBox = MailBox::login($mailAddress);
39        $mail = $mailBox->getMailsBySubject($subject);
40        $mailBox->logout();
41
42        if ($mail->isAsExpected($from, $to, $subject, $message)) {
43            echo "Found the email. {$recipient} received.\n";
44        }
45    }
46}
47?>
48--CLEAN--
49<?php
50require_once __DIR__.'/mail_util.inc';
51$subject = 'mail_bug72964';
52foreach (MailBox::USERS as $mailAddress) {
53    $mailBox = MailBox::login($mailAddress);
54    $mailBox->deleteMailsBySubject($subject);
55    $mailBox->logout();
56}
57?>
58--EXPECT--
59Email sent.
60Found the email. to received.
61Found the email. cc1 received.
62Found the email. cc2 received.
63Found the email. bcc1 received.
64Found the email. bcc2 received.
65