Before you attempt to send an email message using the PHP mail() function, you should make sure the PHP mail() function is actually enabled on the server. You can perform this check by running a small test script. Follow the steps below in order to create this script and execute it:

  1. Open the File Manager section of the Control Panel. 
  2. Make a new file. Call the file something like test.php.
  3. Copy over the code below and save the file.
 <?php
    if(function_exists('mail')) {
        echo "PHP mail() function is enabled";
    }
    else {
        echo "PHP mail() function is not enabled";
    }
 ?>
  1. Now copy the path to the test script and run it in your web browser. The path should look something like http://mydomain.com/test.php.

If all goes well, you should see the message PHP mail() function is enabled.

NOTE - Best practice used by hosting providers to secure sever.

There are so many ways to send email using php. The two main ways to do this is either using PHPMail() or SMTP. 

PHPMail() is open and used by trojans and viruses. Most clients have infected files which just send mails using PHPMail(), because it doesn't authenticate. It doesn't check if the email being sent is actually coming from the domain and this puts a lot of strain on the mail server, making legitimate mails wait in queue for a long time.

SMTP isn't open and the email must be authenticated.... a real email address and password must be written into your code and must be verified by the mail server before the email is sent. This makes the email legitimate.