Page 1 of 1

mail function help

Posted: Wed May 02, 2007 11:06 pm
by barnes529
Hi to all,
i need some help about e mail sending.i am basic learner of php.

Code: Select all

<?php
$to="shyamprasad5292001@gmail.com";
$subject="test mail";
$message="hello!shyam this is sample mail to you.";
$from="shyamprasad_5292001@yahoo.com";
$headers="From:$from";
mail($to,$subject,$message,$headers);
echo "mail sent";
?>
when i run this script i got following errors.how to fix these problems.

Warning: 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:\easyphp1-8\www\mail.php on line 7

i am working on local host.i opened php.ini and saw this SMTP and smtp_port variable.please any one explain all modification in php.ini and reqiurements to send a mail.
barnes is online now Edit/Delete Message

Posted: Wed May 02, 2007 11:14 pm
by aaronhall
You'd need to install an SMTP server on your computer. There are plenty of free Windows servers out there. Once it's installed, the server should default to port 25 unless you specify otherwise, and you should be ready to roll.