Difference between revisions of "PHP email not sending"
From Hostek.com Wiki
(Created page with "==Testing the PHP mail function== To test if the PHP mail function is working, save and run the following script. <pre><?php $message = "This is just a test. Please disregard...") |
(No difference)
|
Revision as of 16:38, 13 June 2014
Testing the PHP mail function
To test if the PHP mail function is working, save and run the following script.
<?php $message = "This is just a test. Please disregard."; if(mail('youremail@domain.com', 'PHP Mail Test', $message)){ echo "sent"; }else{ echo "failed"; } ?>
If it fails, then there is a problem with PHP passing email messages to sendmail.
Troubleshooting
Check the Apache error log file: /usr/local/apache/logs/error_log
If you see an error message like:sendmail: Not running with correct effective GID. Is sendmail binary setgid mailtrap?
To resolve this issue perform the following:
chown root:mailtrap /usr/sbin/sendmail
chmod 2755 /usr/sbin/sendmail