error when trying to e-mail...

A

Anonymous

Guest
Hi. I am using Apache's localhost server, with PHP 5.02. I am trying out the e-mail option with the following simple code:

<?
$to = "dtvonly@yahoo.com";
$subject = "Hi";
$body = "Testing PHP e-mail";
if (mail($to, $subject, $body))
{
echo("<p>Message successfully sent!</p>");
}
else
{
echo("<p>Message delivery failed...</p>");
}
?>

...but got the following error:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\apache group\Apache2\htdocs\daifiles\emailing.php on line 6

Message delivery failed...

I have no idea what to do. Someone please help? Thank you.
 
HI,

you have to modify your code here.

Please download phpmailer class from http://www.phpclasses.org

You are given there smtp options and works fine on local pc and online too.
 
Back
Top