Annotation of embedaddon/php/ext/standard/tests/mail/mail_variation_alt3-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mail() function : basic functionality
3: --SKIPIF--
4: <?php
5: if( substr(PHP_OS, 0, 3) != 'WIN' ) {
6: die('skip...Windows only test');
7: }
8:
9: require_once(dirname(__FILE__).'/mail_skipif.inc');
10: ?>
11: --INI--
12: max_execution_time = 120
13: --FILE--
14: <?php
15: /* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
16: * Description: Send an email message
17: * Source code: ext/standard/mail.c
18: * Alias to functions:
19: */
20:
21: error_reporting(E_ALL & ~E_STRICT);
22: ini_set("SMTP", "localhost");
23: ini_set("smtp_port", 25);
24:
25: echo "*** Testing mail() : basic functionality ***\n";
26: require_once(dirname(__FILE__).'/mail_include.inc');
27: $subject_prefix = "!**PHPT**!";
28:
29: $to = "$username";
30: $subject = "$subject_prefix: Basic PHPT test for mail() function";
31: $message = <<<HERE
32: Description
33: bool mail ( string \$to , string \$subject , string \$message [, string \$additional_headers [, string \$additional_parameters]] )
34: Send an email message
35: HERE;
36:
37: $res = mail($to, $subject, $message);
38:
39: if ($res !== true) {
40: exit("TEST COMPLETED : Unable to send test email\n");
41: } else {
42: echo "Msg sent OK\n";
43: }
44:
45: // Search for email message on the mail server using imap.
46: $imap_stream = imap_open($default_mailbox, $username, $password);
47: if ($imap_stream === false) {
48: echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n";
49: return false;
50: }
51:
52: $found = false;
53: $repeat_count = 20; // we will repeat a max of 20 times
54: while (!$found && $repeat_count > 0) {
55:
56: // sleep for a while to allow msg to be delivered
57: sleep(1);
58:
59: $current_msg_count = imap_check($imap_stream)->Nmsgs;
60:
61: // Iterate over recent msgs to find the one we sent above
62: for ($i = 1; $i <= $current_msg_count; $i++) {
63: // get hdr details
64: $hdr = imap_headerinfo($imap_stream, $i);
65:
66: if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) {
67: echo "Id of msg just sent is $i\n";
68: echo ".. delete it\n";
69: imap_delete($imap_stream, $i);
70: $found = true;
71: break;
72: }
73: }
74:
75: $repeat_count -= 1;
76: }
77:
78: if (!$found) {
79: echo "TEST FAILED: email not delivered\n";
80: } else {
81: echo "TEST PASSED: Msgs sent and deleted OK\n";
82: }
83:
84: imap_close($imap_stream, CL_EXPUNGE);
85: ?>
86: ===Done===
87: --EXPECTF--
88: *** Testing mail() : basic functionality ***
89:
90: Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in %s on line %d
91: TEST COMPLETED : Unable to send test email
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>