Send email by using phpmail function

Send email by mail function

One of the best way to send E-mail using website is php mail function but its also insecure, so be careful while using php mail function to send an E-mail.

Most of the web hosting provider disabled php mail function on shared server to stop spamming from server by hackers.

If you have your own server and want to send E-mail using php mail function then simply copy and paste following code in a php file and use it to send an E-mail.

————————–

<?
$to      = ‘supp0rt@xyz.com’;
$subject = ‘The test for mail function’;
$message = ‘Hello’;
$headers = ‘From: test@abc123.com’ . “\r\n” .
‘Reply-To: test@testforever123.com’ . “\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@ktchost []# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

root@ktchost []# cat /usr/local/lib/php.ini | grep disable_function
disable_functions=”system,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,highlight_file,phpmail”

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

Or

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

Post similar to this post : Send email using form mail perl script

 

About Anant 384 Articles
Senior technical writer

1 Trackbacks & Pingbacks

  1. Send email by using form mail function - KTCHost

Comments are closed.