1--TEST-- 2Bug #72964 (White space not unfolded for CC/Bcc headers) 3--SKIPIF-- 4<?php 5if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only test'); 6if (getenv("SKIP_SLOW_TESTS")) die('skip slow test'); 7require_once __DIR__ . '/mail_skipif.inc'; 8?> 9--INI-- 10SMTP=localhost 11smtp_port=25 12--FILE-- 13<?php 14require_once __DIR__ . '/mail_include.inc'; 15 16function find_and_delete_message($username, $subject) { 17 global $default_mailbox, $password; 18 19 $imap_stream = imap_open($default_mailbox, $username, $password); 20 if ($imap_stream === false) { 21 die("Cannot connect to IMAP server $server: " . imap_last_error() . "\n"); 22 } 23 24 $found = false; 25 $repeat_count = 20; // we will repeat a max of 20 times 26 while (!$found && $repeat_count > 0) { 27 // sleep for a while to allow msg to be delivered 28 sleep(1); 29 30 $num_messages = imap_check($imap_stream)->Nmsgs; 31 for ($i = $num_messages; $i > 0; $i--) { 32 $info = imap_headerinfo($imap_stream, $i); 33 if ($info->subject === $subject) { 34 imap_delete($imap_stream, $i); 35 $found = true; 36 break; 37 } 38 } 39 $repeat_count--; 40 } 41 42 imap_close($imap_stream, CL_EXPUNGE); 43 return $found; 44} 45 46$to = "{$users[2]}@$domain"; 47$subject = bin2hex(random_bytes(16)); 48$message = 'hello'; 49$headers = "From: webmaster@example.com\r\n" 50 . "Cc: {$users[0]}@$domain,\r\n\t{$users[1]}@$domain\r\n" 51 . "Bcc: {$users[2]}@$domain,\r\n {$users[3]}@$domain\r\n"; 52 53$res = mail($to, $subject, $message, $headers); 54if ($res !== true) { 55 die("TEST FAILED : Unable to send test email\n"); 56} else { 57 echo "Message sent OK\n"; 58} 59 60foreach ($users as $user) { 61 if (!find_and_delete_message("$user@$domain", $subject)) { 62 echo "TEST FAILED: email not delivered\n"; 63 } else { 64 echo "TEST PASSED: Message sent and deleted OK\n"; 65 } 66} 67?> 68--EXPECT-- 69Message sent OK 70TEST PASSED: Message sent and deleted OK 71TEST PASSED: Message sent and deleted OK 72TEST PASSED: Message sent and deleted OK 73TEST PASSED: Message sent and deleted OK 74