mail function help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
barnes529
Forum Newbie
Posts: 17
Joined: Thu Apr 19, 2007 4:18 am

mail function help

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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.
Post Reply