6

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 = "myemail@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a test message.";
$from = "someonelse@gmail.com";
$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!

Vijaya Pandey
  • 4,252
  • 5
  • 32
  • 57
  • have you restart your apache server? restart it. – Yogesh Suthar May 02 '13 at 04:58
  • 3
    do a phpinfo() inside your script to verify that the settings in effect are the ones you've set. Sometimes there are multiple php.ini files, you may be changing the wrong one (phpinfo will also tell you the location to the loaded php.ini file) – periklis May 02 '13 at 05:22

1 Answers1

6

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!

Vijaya Pandey
  • 4,252
  • 5
  • 32
  • 57
  • Failed to connect to mailserver at smtp.wlink.com.np port 25, verify your SMTP and smtp_port setting in php.ini. – dipak_pusti May 13 '17 at 18:10