PHP email function

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
prog
Forum Newbie
Posts: 2
Joined: Thu Feb 23, 2012 5:54 am

PHP email function

Post by prog »

HI,

I am using the following email function to mail

Code: Select all

<?php
$to = "xxx@xxx.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers))
{ echo "Mail sent"; }
else
{ echo "Mail failed"; }

?>
Im getting the error :
Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
But mt PHP.ini settings are:
SMTP 127.0.0.1
smtp_port 25

Anyone plz help...
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP email function

Post by Celauran »

Do you have a mail server running locally and listening on port 25?
prog
Forum Newbie
Posts: 2
Joined: Thu Feb 23, 2012 5:54 am

Re: PHP email function

Post by prog »

No, I dont have server access with me & its not here
Post Reply