Sending e-mail via SendMail Service

Things to take note of and as follows:


  • log-in as root 
  • make sure that sendmail service is running
  • the default executable is found in /usr/sbin/sendmail 
  • add: the following lines at the configuration directives
    • sendmail_path=/usr/sbin/sendmail
    • where /usr/sbin/sendmail is the actual path to the sendmail executable and related .dso files
    • you can check the log after execution, it's at /var/log/maillog
    • sample code below:
      • <?php
      •   $to = 'root@localhost';
      •   $sub = 'sample text message ' . date('d-m-y h:i:s');
      •   $body = 'this is a test, a sample page for display only';
      •   $rest = mail($to, $sub, $body);
      •   if ($rest == false) {

                         echo 'Error.....';

                       } else {

                            echo 'send mail Ok !!!';

                          }

      • ?>