Saturday, October 31, 2009

How to check mail function working or not with php

this is the sample code to check whether the mail function is working or not in your hosting server in php. save the code in a file like mailtest.php in root directory and run it.


$to = "";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

if (mail($to, $subject, $body, $headers))
echo "

Message successfully sent!

echo "

Message delivery failed...



hope it will help you.

1 comment:

  1. Nice website full of quite interesting and informative posts, so must keep on good working!