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.
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
or just php script.php