It`s simple when you know how ! CentOS,Linux check if php can send mail on linux

check if php can send mail on linux

check if PHP-scripts can send emails: from console or putty session to the server

php -a
mail ('you@example.com', "Test Postfix", "Test mail from postfix");
exit ();

Note: if after running php -a, you get "Interactive mode enabled" message but no php> prompt, then your PHP is not compiled with readline support. If its working nice, you will get only "Interactive mode" message with php> prompt.

You can still run test though. Just create a testmail.php with following lines of codes:

<?php
    mail ('you@example.com', "Test Postfix", "Test mail from postfix");
?>

and run it on your server with php -f testmail.php command. If you can’t see any email form PHP, then that means its PHP’s fault.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post