mail_log.phpt 915 B

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