niko
niko

Reputation: 9393

What does the below Warning mean?

  <?php
   $to = "[email protected]";
   $subject = "Test mail";
   $message = "Hello! This is a simple email message.";
   $from = "[email protected]";
   $headers = "From:" . $from;
   mail($to,$subject,$message,$headers);
   echo "Mail Sent.";
 ?>

When I run these script I get these 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:\xampp\htdocs\website\mail.php on line 7 

What I have to do now? Could anyone tell me the way to do it ? Okay I have found that file but what are the fields I need to update could you suggest me some code so that i paste it these and save?

Upvotes: 0

Views: 93

Answers (3)

Ofir
Ofir

Reputation: 415

I guess that this question is the same as your other question...

If so, I guess you are trying to send an email through GMail's SMTP server. Their server requires authentication, which PHP's mail function doesn't support. As I answered you in the other question, you can use Zend_Mail to do this. You can also use PEAR Mail like in the example in the other question. Either way you will need to download some external file, include it in your code and use it.

Upvotes: 1

David
David

Reputation: 218837

You need to configure PHP to use a working SMTP service in order to send SMTP email. Here's an article that discusses the subject.

Basically, it appears that the SMTP configuration for your PHP instance is using default values, which point to localhost. But your local computer doesn't seem to be running an SMTP service. So you'll need to point is to a server that is running one, and one which your application is permitted to use.

Upvotes: 1

Cydonia7
Cydonia7

Reputation: 3826

You have to configure your php.ini with a valid smtp server and email address.

Upvotes: 2

Related Questions