Problem with mail() on Win2003 Server

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
anpal
Forum Newbie
Posts: 2
Joined: Wed May 25, 2005 10:37 am

Problem with mail() on Win2003 Server

Post by anpal »

Hello everybody

I'm running Windows 2003 Server + IIS6 + PHP.
Now I've tried to send mail with php and got the following error:

Code: Select all

Warning: mail(): Failed to connect to mailserver at &quote;localhost&quote; port 25, 
verify your &quote;SMTP&quote; and &quote;smtp_port&quote; setting in php.ini or 
use ini_set() in c:\inetpub\wwwroot\testmail.php on line
The fact is that I have got SMTP server instaled on this machine on 25th port.
And SMTP server does work (I can send email throuht it, but not with php).

I also tried to change SMTP in php.ini to my ISP's SMTP-server.
In that case the error is the same but instead "localhost" goes "smtp.provider.net". Provider's SMTP works too, and I can send email through it from this machine (that hosts IIS and PHP).

May it be the problem of Win2003 Security or something else?

Could anybody tell me something about this problem?

Thank you very much.
anpal
Forum Newbie
Posts: 2
Joined: Wed May 25, 2005 10:37 am

Little more about the problem

Post by anpal »

Furthermore, I've installed sockets extension and tried the following code:

Code: Select all

$s = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if(socket_connect($s,&quote;localhost&quote;,25))
{
	socket_close($s);
	echo(&quote;socket ok&quote;);
}else
{
	echo(&quote;socket failed&quote;);
}
And this code works well and displays "socket ok".

What could it be in this case?
mrchiu
Forum Newbie
Posts: 13
Joined: Sat May 28, 2005 3:33 pm

Post by mrchiu »

Did you set the relay in smtp settings? You have to grant 127.0.0.1 to enable php to have access.
Post Reply