9

Possible Duplicate:
Failed to connect to mailserver at “localhost” port 25

I used this one however

$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$txt,$headers);

I have this error which is Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Community
  • 1
  • 1
  • 1
    So have you followed the suggestion in the error message? *Are* you running a local SMTP server? – Jon Skeet Jan 04 '11 at 07:10
  • This means that you don't have an SMTP server running on your local machine. Use your ISP or company's SMTP server as the host. – StuartLC Jan 04 '11 at 07:10

1 Answers1

19

If you are running your application just on localhost and it is not yet live, I believe it is very difficult to send mail using this.

Once you put your application online, I believe that this problem should be automatically solved. By the way,ini_set() helps you to change the values in php.ini during run time.

This is the same question as Failed to connect to mailserver at "localhost" port 25

also check this php mail function not working

Community
  • 1
  • 1
Programmer
  • 6,565
  • 25
  • 78
  • 125