diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/mail | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/mail')
22 files changed, 1500 insertions, 0 deletions
diff --git a/ext/standard/tests/mail/bug51604.phpt b/ext/standard/tests/mail/bug51604.phpt new file mode 100644 index 0000000..a657021 --- /dev/null +++ b/ext/standard/tests/mail/bug51604.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #51604 (newline in end of header is shown in start of message) +--INI-- +sendmail_path=tee mail_bug51604.out >/dev/null +mail.add_x_header = Off +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = "KHeaders\n\n\n\n\n"; +$outFile = "mail_bug51604.out"; +@unlink($outFile); + +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECT-- +bool(true) +To: user@company.com +Subject: Test Subject +KHeaders + +A Message +===DONE=== diff --git a/ext/standard/tests/mail/ezmlm_hash_basic.phpt b/ext/standard/tests/mail/ezmlm_hash_basic.phpt new file mode 100644 index 0000000..ce70eac --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ezmlm_hash() function : basic functionality +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php +/* Prototype : int ezmlm_hash ( string $addr ) + * Description: Calculate the hash value needed by EZMLM. + * Source code: ext/standard/mail.c + */ + +echo "*** Testing ezmlm_hash() : basic functionality ***\n"; + +var_dump(ezmlm_hash(b"webmaster@somewhere.com")); +var_dump(ezmlm_hash(b"foo@somewhere.com")); + +?> +===Done=== +--EXPECT-- +*** Testing ezmlm_hash() : basic functionality *** +int(1) +int(7) +===Done=== diff --git a/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt b/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt new file mode 100644 index 0000000..03ac67b --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ezmlm_hash() function : basic functionality +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php +/* Prototype : int ezmlm_hash ( string $addr ) + * Description: Calculate the hash value needed by EZMLM. + * Source code: ext/standard/mail.c + */ + +echo "*** Testing ezmlm_hash() : basic functionality ***\n"; + +var_dump(ezmlm_hash(b"webmaster@somewhere.com")); +var_dump(ezmlm_hash(b"foo@somewhere.com")); + +?> +===Done=== +--EXPECT-- +*** Testing ezmlm_hash() : basic functionality *** +int(1) +int(7) +===Done=== diff --git a/ext/standard/tests/mail/ezmlm_hash_error.phpt b/ext/standard/tests/mail/ezmlm_hash_error.phpt new file mode 100644 index 0000000..c5f49dd --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_error.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test ezmlm_hash() function : error conditions +--FILE-- +<?php +/* Prototype : int ezmlm_hash ( string $addr ) + * Description: Calculate the hash value needed by EZMLM. + * Source code: ext/standard/mail.c + */ + +echo "*** Testing ezmlm_hash() : error conditions ***\n"; + +echo "\n-- Testing ezmlm_hash() function with fewer than expected no. of arguments --\n"; +var_dump( ezmlm_hash() ); + +echo "\n-- Testing ezmlm_hash() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( ezmlm_hash("webmaster@example.com", $extra_arg) ); + +echo "\n-- Testing ezmlm_hash() function with invalid input - ARRAY --\n"; +$array_arg = array(1,2,3,4); +$extra_arg = 10; +var_dump( ezmlm_hash($array_arg) ); + +echo "\n-- Testing ezmlm_hash() function with invalid input - OBJECT without 'cast_object' method --\n"; +class sample { +} + +$obj_arg = new sample(); +var_dump( ezmlm_hash($obj_arg) ); + +echo "\n-- Testing ezmlm_hash() function with invalid input - RESOURCE --\n"; +$file_handle = fopen(__FILE__, "r"); +$extra_arg = 10; +var_dump( ezmlm_hash($file_handle) ); +fclose($file_handle); + +?> +===DONE=== +--EXPECTF-- +*** Testing ezmlm_hash() : error conditions *** + +-- Testing ezmlm_hash() function with fewer than expected no. of arguments -- + +Warning: ezmlm_hash() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with more than expected no. of arguments -- + +Warning: ezmlm_hash() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - ARRAY -- + +Warning: ezmlm_hash() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - OBJECT without 'cast_object' method -- + +Warning: ezmlm_hash() expects parameter 1 to be string, object given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - RESOURCE -- + +Warning: ezmlm_hash() expects parameter 1 to be string, resource given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/mail/ezmlm_hash_variation1.phpt b/ext/standard/tests/mail/ezmlm_hash_variation1.phpt new file mode 100644 index 0000000..aa1e521 --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_variation1.phpt @@ -0,0 +1,193 @@ +--TEST-- +Test explode() function : usage variations - test values for $delimiter argument +--FILE-- +<?php + +/* Prototype : array explode ( string $delimiter , string $string [, int $limit ] ) + * Description: Split a string by string. + * Source code: ext/standard/string.c +*/ + +echo "*** Testing explode() function: with unexpected inputs for 'delimiter' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $delimeter +$delimeters = array ( + + // integer values + 0, + 1, + 255, + 256, + PHP_INT_MAX, + -PHP_INT_MAX, + + // float values + 10.5, + -20.5, + 10.1234567e10, + + // array values + array(), + array(0), + array(1, 2), + + // boolean values + true, + false, + TRUE, + FALSE, + + // null values + NULL, + null, + + // objects + new sample(), + + // resource + $file_handle, + + // undefined variable + @$undefined_var, + + // unset variable + @$unset_var +); + +// loop through with each element of the $delimeters array to test explode() function +$count = 1; +$string = "piece1 piece2 piece3 piece4 piece5 piece6"; +$limit = 5; +foreach($delimeters as $delimeter) { + echo "-- Iteration $count --\n"; + var_dump( explode($delimeter, $string, $limit) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===Done=== +--EXPECTF-- +*** Testing explode() function: with unexpected inputs for 'delimiter' argument *** +-- Iteration 1 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 2 -- +array(2) { + [0]=> + string(5) "piece" + [1]=> + string(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 3 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 4 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 5 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 6 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 7 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 8 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 9 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 10 -- + +Warning: explode() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: explode() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: explode() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 13 -- +array(2) { + [0]=> + string(5) "piece" + [1]=> + string(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 14 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 15 -- +array(2) { + [0]=> + string(5) "piece" + [1]=> + string(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 16 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 19 -- +array(1) { + [0]=> + string(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 20 -- + +Warning: explode() expects parameter 1 to be string, resource given in %s on line %d +NULL +-- Iteration 21 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +===Done=== diff --git a/ext/standard/tests/mail/mail_basic.phpt b/ext/standard/tests/mail/mail_basic.phpt new file mode 100644 index 0000000..fecb50f --- /dev/null +++ b/ext/standard/tests/mail/mail_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path=tee mailBasic.out >/dev/null +mail.add_x_header = Off +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = 'KHeaders'; +$outFile = "mailBasic.out"; +@unlink($outFile); + +echo "-- All Mail Content Parameters --\n"; +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + +echo "\n-- Mandatory Parameters --\n"; +// Calling mail() with mandatory arguments +var_dump( mail($to, $subject, $message) ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- All Mail Content Parameters -- +bool(true) +To: user@company.com +Subject: Test Subject +KHeaders + +A Message + +-- Mandatory Parameters -- +bool(true) +To: user@company.com +Subject: Test Subject + +A Message +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic2.phpt b/ext/standard/tests/mail/mail_basic2.phpt new file mode 100644 index 0000000..8967d18 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic2.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--INI-- +sendmail_path="cat > /tmp/php_test_mailBasic2.out" +mail.add_x_header = Off +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = 'KHeaders'; +$additional_parameters = "-n"; +$outFile = "/tmp/php_test_mailBasic2.out"; +@unlink($outFile); + +echo "-- extra parameters --\n"; +// Calling mail() with all possible arguments +var_dump( mail($to, $subject, $message, $additional_headers, $additional_parameters) ); + +echo file_get_contents($outFile); +unlink($outFile); +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +-- extra parameters -- +bool(true) +%w1%wTo: user@company.com +%w2%wSubject: Test Subject +%w3%wKHeaders +%w4%w +%w5%wA Message +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic3.phpt b/ext/standard/tests/mail/mail_basic3.phpt new file mode 100644 index 0000000..58eae03 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic3.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit 1" +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; + + +echo "-- failure --\n"; +var_dump( mail($to, $subject, $message) ); +?> +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic4.phpt b/ext/standard/tests/mail/mail_basic4.phpt new file mode 100644 index 0000000..9ecc886 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic4.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit 1" +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; + + +echo "-- failure --\n"; + +var_dump( mail($to, $subject, $message) ); +?> +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic5.phpt b/ext/standard/tests/mail/mail_basic5.phpt new file mode 100644 index 0000000..7e42ccb --- /dev/null +++ b/ext/standard/tests/mail/mail_basic5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit 1" +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; + +echo "-- failure --\n"; +var_dump( mail($to, $subject, $message) ); +?> +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt new file mode 100644 index 0000000..3c4dd88 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt @@ -0,0 +1,95 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php + +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); +ini_set("SMTP", "localhost"); +ini_set("smtp_port", 25); +ini_set("sendmail_from", "user@company.com"); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$res = mail($to, $subject, $message); + +if ($res !== true) { + exit("TEST FAILED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt new file mode 100644 index 0000000..d7bae62 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$extra_headers = "from: user@company.com"; + +$res = mail($to, $subject, $message, $extra_headers); + +if ($res !== true) { + exit("TEST FAILED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt new file mode 100644 index 0000000..86b57eb --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$extra_headers = "FRom: user@company.com"; + +$res = mail($to, $subject, $message, $extra_headers); + +if ($res !== true) { + exit("TEST FAILED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt new file mode 100644 index 0000000..f4a9d46 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt @@ -0,0 +1,94 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$extra_headers = "from: user@company.com"; +$extra_parameters = "addons"; // should be ignored + +$res = mail($to, $subject, $message, $extra_headers, $extra_parameters); + +if ($res !== true) { + exit("TEST FAILED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_error.phpt b/ext/standard/tests/mail/mail_error.phpt new file mode 100644 index 0000000..871b6da --- /dev/null +++ b/ext/standard/tests/mail/mail_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test mail() function : error conditions +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : error conditions ***\n"; + + +//Test mail with one more than the expected number of arguments +echo "\n-- Testing mail() function with more than expected no. of arguments --\n"; +$to = 'string_val'; +$subject = 'string_val'; +$message = 'string_val'; +$additional_headers = 'string_val'; +$additional_parameters = 'string_val'; +$extra_arg = 10; +var_dump( mail($to, $subject, $message, $additional_headers, $additional_parameters, $extra_arg) ); + +// Testing mail with one less than the expected number of arguments +echo "\n-- Testing mail() function with less than expected no. of arguments --\n"; +$to = 'string_val'; +$subject = 'string_val'; +var_dump( mail($to, $subject) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : error conditions *** + +-- Testing mail() function with more than expected no. of arguments -- + +Warning: mail() expects at most 5 parameters, 6 given in %s on line %d +NULL + +-- Testing mail() function with less than expected no. of arguments -- + +Warning: mail() expects at least 3 parameters, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/mail/mail_include.inc b/ext/standard/tests/mail/mail_include.inc new file mode 100644 index 0000000..a0ff5e0 --- /dev/null +++ b/ext/standard/tests/mail/mail_include.inc @@ -0,0 +1,150 @@ +<?php +// Change these to make tests run successfully +$server = '{localhost}'; +$default_mailbox = $server . "INBOX"; +$domain = "example.com"; +$admin_user = "webmaster"; // a user with admin access +$username = "$admin_user@$domain"; +$password = 'p4ssw0rd'; +$users = array("webmaster", "info", "admin", "foo"); // tests require 4 valid userids +$mailbox_prefix = "phpttest"; // name used for test mailbox + +/** + * Create a test mailbox and populate with msgs + * + * @para, string mailbox_suffix Suffix used to uniquely identify mailboxes + * @param int message_count number of test msgs to be written to new mailbox + * + * @return IMAP stream to new mailbox on sucesss; FALSE on failure + */ +function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = null, $msg_type = "simple"){ + global $server, $default_mailbox, $username, $password; + + // open a stream to default mailbox + $imap_stream = imap_open($default_mailbox, $username, $password); + + if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; + } + + echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; + $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); + if ($new_mailbox === false) { + echo "Cant create a temporary mailbox: " . imap_last_error(). "\n"; + return false; + } + + echo ".. mailbox '$new_mailbox' created\n"; + + // reopen stream to new mailbox + if (imap_reopen($imap_stream, $new_mailbox) === false) { + echo "cant re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; + return false; + } + + return $imap_stream; +} + +/** + * Create mailbox and fill with generic emails + * + * @param resource $imap_stream + * @param string $mailbox + */ +function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type= "simple"){ + global $default_mailbox, $mailbox_prefix; + $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; + + $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); + + // check mailbox does not already exist + if ($mailboxes) { + foreach($mailboxes as $value) { + if ($value->name == $mailbox) { + exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); + } + } + } + + if (imap_createmailbox($imap_stream, $mailbox) === false) { + return false; + } + + // Add number of test msgs requested + if ($message_count > 0) { + populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); + } + + return $mailbox; +} + +/** + * Populate a mailbox with generic emails + * + * @param resource $imap_stream + * @param string $mailbox + */ +function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "simple"){ + + global $users, $domain; + + for($i = 1; $i <= $message_count; $i++) { + if ($msg_type == "simple") { + $msg = "From: foo@anywhere.com\r\n" + . "To: $users[0]@$domain\r\n" + . "Subject: test$i\r\n" + . "\r\n" + . "$i: this is a test message, please ignore\r\n"; + } else { + $envelope["from"]= "foo@anywhere.com"; + $envelope["to"] = "$users[0]@$domain"; + $envelope["subject"] = "Test msg $i"; + + $part1["type"] = TYPEMULTIPART; + $part1["subtype"] = "mixed"; + + $part2["type"] = TYPETEXT; + $part2["subtype"] = "plain"; + $part2["description"] = "imap_mail_compose() function"; + $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; + + $part3["type"] = TYPETEXT; + $part3["subtype"] = "plain"; + $part3["description"] = "Example"; + $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; + + $part4["type"] = TYPETEXT; + $part4["subtype"] = "plain"; + $part4["description"] = "Return Values"; + $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; + + $body[1] = $part1; + $body[2] = $part2; + $body[3] = $part3; + $body[4] = $part4; + + $msg = imap_mail_compose($envelope, $body); + } + + imap_append($imap_stream, $mailbox, $msg); + } +} + +/** + * Get the mailbox name from a mailbox decription, i.e strip off server details. + * + * @param string mailbox complete mailbox name + * @return mailbox name + */ +function get_mailbox_name($mailbox){ + + if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { + echo "Unrecpognized mailbox name\n"; + return false; + } + + return $match[1]; +} + +?> diff --git a/ext/standard/tests/mail/mail_skipif.inc b/ext/standard/tests/mail/mail_skipif.inc new file mode 100644 index 0000000..0065940 --- /dev/null +++ b/ext/standard/tests/mail/mail_skipif.inc @@ -0,0 +1,26 @@ +<?php +extension_loaded('imap') or die('skip imap extension not available in this build'); + +if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) { + // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, + // the code below didn't skip test even though there was no mail server + // test then failed (no mail server to test against) + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); + // imap uses tcp port 143 + socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); +} + +// Change these to make tests run successfully +$mailbox = '{localhost}'; +$username = 'webmaster@example.com'; +$password = 'p4ssw0rd'; +$options = OP_HALFOPEN; // this should be enough to verify server present +$retries = 0; // dont retry connect on failure + +$mbox = imap_open($mailbox, $username, $password, $options, $retries); +if (!$mbox) { + die("skip could not connect to mailbox $mailbox"); +} +imap_close($mbox); +?> diff --git a/ext/standard/tests/mail/mail_variation1.phpt b/ext/standard/tests/mail/mail_variation1.phpt new file mode 100644 index 0000000..bf37bf4 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test mail() function : variation invalid program for sendmail +--INI-- +sendmail_path=rubbish 2>/dev/null +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : variation ***\n"; + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +var_dump( mail($to, $subject, $message) ); +?> +===DONE=== +--EXPECT-- +*** Testing mail() : variation *** +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_variation2.phpt b/ext/standard/tests/mail/mail_variation2.phpt new file mode 100644 index 0000000..c16c270 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation2.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test mail() function : variation force extra parameters +--INI-- +sendmail_path="cat > /tmp/php_test_mailVariation2.out" +mail.force_extra_parameters="-n" +mail.add_x_header = Off +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +echo "*** Testing mail() : basic functionality ***\n"; + + +// Initialise all required variables +$to = 'user@company.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$outFile = "/tmp/php_test_mailVariation2.out"; +@unlink($outFile); + +var_dump( mail($to, $subject, $message) ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +bool(true) +%w1%wTo: user@company.com +%w2%wSubject: Test Subject +%w3%w +%w4%wA Message +===DONE=== diff --git a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt new file mode 100644 index 0000000..b81f3af --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); +ini_set("SMTP", "localhost"); +ini_set("smtp_port", 2525); +ini_set("sendmail_from", "user@company.com"); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$res = mail($to, $subject, $message); + +if ($res !== true) { + exit("TEST COMPLETED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): Failed to connect to mailserver at "localhost" port 2525, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in %s on line %d +TEST COMPLETED : Unable to send test email diff --git a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt new file mode 100644 index 0000000..6ae06bb --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); +ini_set("SMTP", "localplace"); +ini_set("smtp_port", 25); +ini_set("sendmail_from", "user@company.com"); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$res = mail($to, $subject, $message); + +if ($res !== true) { + exit("TEST COMPLETED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): Failed to connect to mailserver at "localplace" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in %s on line %d +TEST COMPLETED : Unable to send test email diff --git a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt new file mode 100644 index 0000000..4062fae --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt @@ -0,0 +1,91 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip...Windows only test'); +} + +require_once(dirname(__FILE__).'/mail_skipif.inc'); +?> +--INI-- +max_execution_time = 120 +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(E_ALL & ~E_STRICT); +ini_set("SMTP", "localhost"); +ini_set("smtp_port", 25); + +echo "*** Testing mail() : basic functionality ***\n"; +require_once(dirname(__FILE__).'/mail_include.inc'); +$subject_prefix = "!**PHPT**!"; + +$to = "$username"; +$subject = "$subject_prefix: Basic PHPT test for mail() function"; +$message = <<<HERE +Description +bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] ) +Send an email message +HERE; + +$res = mail($to, $subject, $message); + +if ($res !== true) { + exit("TEST COMPLETED : Unable to send test email\n"); +} else { + echo "Msg sent OK\n"; +} + +// Search for email message on the mail server using imap. +$imap_stream = imap_open($default_mailbox, $username, $password); +if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; +} + +$found = false; +$repeat_count = 20; // we will repeat a max of 20 times +while (!$found && $repeat_count > 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in %s on line %d +TEST COMPLETED : Unable to send test email |