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.



<?php

$to = "sendermail@domain.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$headers = 'From: sendermail@domain.com' . "\r\n" .
'Reply-To: skmliton@yahoo.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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

Message successfully sent!

";
}
else
{
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! http://www.lowhosting.com/siteground-review

    ReplyDelete