To check if mail function is enabled on your apache server you can try one of the following:
Check your php.ini like this:
1 2 3 |
<?php phpinfo(); ?> |
You should search for this in the list sendmail_path that has the default value /usr/sbin/sendmail -t -i
You can also try to manual set it to this value by changing the php.ini file. To do this go to /etc/php5/apache2/php.ini and uncomment the sendmail_path line like this
1 2 3 |
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "/usr/sbin/sendmail -t -i" |
If it did not work for you, try to find out if the function exists in the first place.
1 2 3 4 5 6 7 8 9 10 |
<?php if ( function_exists( 'mail' ) ) { echo 'mail() is available'; } else { echo 'mail() has been disabled'; } ?> |
And finally you can test what the php mail() function returns.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?php /* * Enable error reporting */ ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); /* * Setup email addresses and change it to your own */ $from = "your_email@yourdomain.com"; $to = "send_to@testdomain.com"; $subject = "Simple test for mail function"; $message = "This is a test to check if php mail function sends out the email"; $headers = "From:" . $from; /* * Test php mail function to see if it returns "true" or "false" * Remember that if mail returns true does not guarantee * that you will also receive the email */ if(mail($to,$subject,$message, $headers)) { echo "Test email send."; } else { echo "Failed to send."; } ?> |
But more important than this is if the email arrives to your inbox (or Spam folder).
I have also find myself in need to check the mail function a WordPress platform. You can do this on WordPress by installing Check Email plugin. Although it has not been updated lately it still works and it does the job that it was installed for.
Like I said, a positive result does not mean that the email will be received. There are much more things to check here.
Hope this helped you. If not please let me know how you finally solve it.