Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I changed the SMTP and SMTP Port but it still says Failed to connect to mailserver at "localhost" port 25

Tags:

php

sendmail

I am currently using xampp 1.7.0 and my php version is 5.2.8

I changed my php.ini file to:

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465

and my send_email.php file looks like:

$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a test message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

But, it shows the following message:

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\NFL\send_email.php on line 15

Line number 15 is:

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

How can I resolve this issue?

Note: I also added a 5th parameter to the mail call to force the system to use the From Email Address, but it didn't worked!

like image 284
Vijaya Pandey Avatar asked May 02 '13 04:05

Vijaya Pandey


1 Answers

I got the solution to my own question. The problem was:

At first I was changing the php.ini file from C:\xampp\php\

But, when I did

 echo phpinfo();
 die();

I found the loaded configuration file was:

C:\xampp\apache\bin\php.ini

So, I changed

SMTP = localhost
smtp_port = 25

to

SMTP = smtp.wlink.com.np
smtp_port = 25

And it worked!

like image 98
Vijaya Pandey Avatar answered Sep 28 '22 02:09

Vijaya Pandey