Send mail by using phpmail function.

You can create a simple php mail form by using following code..


$to      = ‘’;
$subject = ‘The test for mail function’;
$message = ‘Hello’;
$headers = ‘From:’ . “\r\n” .
‘Reply-To:’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);


If you are not able to receive the E-mail then you need to check whether your server is allowing to send an E-mail by using phpmail() or not?’ if you are having root login then check the servers main php.ini file.

root@server []# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

root@server []# cat /usr/local/lib/php.ini | grep disable_function

and remove the phpmail() from server mail php.ini file and restart the Apache web server.


If you are not having root login details then contact your hosting provider and ask them to enable the phpmail() for your hosting account.

You can also send me an E-mail at if you have any queries…



Both comments and pings are currently closed.

Comments are closed.