xref: /PHP-5.6/ext/standard/tests/mail/mail_log.phpt (revision 37137271)
1--TEST--
2Test mail() function : mail.log ini setting
3--INI--
4sendmail_path=tee /tmp/mail.out >/dev/null
5mail.log = /tmp/mail.log
6--SKIPIF--
7<?php
8if(substr(PHP_OS, 0, 3) == "WIN")
9  die("skip Won't run on Windows");
10?>
11--FILE--
12<?php
13date_default_timezone_set("UTC");
14
15$logfile = ini_get("mail.log");
16if (file_exists($logfile)) {
17	unlink($logfile);
18}
19touch($logfile);
20clearstatcache();
21
22$to = "test@example.com";
23$subject = "mail.log test";
24$message = "Testing mail.log";
25$headers = "X-Test: 1";
26
27var_dump(filesize($logfile) == 0);
28clearstatcache();
29
30var_dump(mail($to, $subject, $message, $headers));
31
32var_dump(filesize($logfile) > 0);
33clearstatcache();
34
35echo file_get_contents($logfile);
36?>
37Done
38--CLEAN--
39<?php
40unlink("/tmp/mail.log");
41unlink("/tmp/mail.out");
42?>
43--EXPECTF--
44bool(true)
45bool(true)
46bool(true)
47[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1
48Done
49