error when trying to e-mail...

the mail() function

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Oct 05, 2006 1:54 pm

Tue Oct 24, 2006 7:52 pm

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 = "";
$subject = "Hi";
$body = "Testing PHP e-mail";
if (mail($to, $subject, $body))
echo("<p>Message successfully sent!</p>");
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.

User avatar
New php-forum User
New php-forum User
Posts: 156
Joined: Wed Mar 22, 2006 2:22 am
Location: Ahmedabad, Gujarat, India

Mon Nov 06, 2006 12:40 am


you have to modify your code here.

Please download phpmailer class from

You are given there smtp options and works fine on local pc and online too.
Mukesh Variya
Zend Framework and Offshore Web Developer Ahmedabad Gujarat India
Customize Application Development Ahmedabad Gujarat India
2 PR Blog Link Exchange with my blog

Post Reply