How do I view PHP mail() errors? How do I see php mail() error log file under UNIX or Linux?
Usually, mail log including errors are sent to your systems mail server log directory. If you are using CentOS / RHEL / Redhat or Fedora Linux, check /var/log/maillog file using any one of the following command:
# tail -f /var/log/maillog
# grep 'user@example.com' /var/log/maillog
# more /var/log/maillog
If you are using Ubuntu or Debian Linux, check /var/log/mail.err and /var/log/mail.log files:
# tail -f /var/log/mail.log
# tail -f /var/log/mail.err
Sample PHP Code To Test Your Log File
Create a php code or upload a file called mailtest.php as follows:
<html> <head> <title>nixCraft PHP: Test mail() </title> </head> <body> <?php $email = "you@example.com"; $subject = "Happy Birthday!"; $msg = "Wishing you all the great things in life, hope this day will bring you an extra share of all that makes you happiest."; mail($email,$subject,$msg); ?> </body> </html>
Run this as:
http://example.com/mailtest.php
And check your server log files as mentioned above.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 1 comment… read it below or add one }
or just php script.php