# Solved: making SMTP work on server



## webzard (May 20, 2008)

Hi... I'm new to server admin and I am running a Windows Server 2003 with Apache 2.2.8 and PHP 5.

I'm running a CMS which has the ability to send mail to its users, but it's not working right now. I've specified to the CMS to use SMTP instead of the other modes (which I also tried and they didn't work).

Here is my settings in the php ini file:


```
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected]
```
Also, when I installed PHP I had the SMTP extension installed as well, and at the end of the PHP ini file there is this:


```
[PHP_SMTP]
extension=php_smtp.dll
```
In the Apache error logs I get this:


```
[Tue May 20 12:38:01 2008] [error] [client 198.15.82.25] PHP Warning:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to localhost:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\r\n) in C:\\somedirectory\\class.smtp.php on line 105, referer: http://mypage/myscript.php
```
I don't know how to proceed from here... What can I do? Did I leave something out when installing? Is there some other diagnostic thing I can do? Any help is appreciated,

~j


----------



## tomdkat (May 6, 2006)

Well, the "unable to connect to localhost:25" is the important information. That means your mail server is either:

not running
not accepting SMTP connections on port 25
being blocked by a firewall that needs to be configured to allow connections on port 25 from localhost
So, make sure your mail server is actually up and running and that any firewalls that might be on the server are properly configured.

Peace...


----------



## TechGuy (Feb 12, 1999)

Just to be completely safe, you can try running *telnet localhost 25* from a command line to make sure it responds to that. You might also try putting in your computer's full domain name (FQDN) in place of localhost to see if that helps.


----------



## webzard (May 20, 2008)

actually I figured out that SMTP isn't running on that server... however there is a SMTP mail server that I could use instead of localhost...

The problem is that I've changed this line in php.ini so that it reflects this new mail server:


```
[mail function]
; For Win32 only.
SMTP = mail.mymailserver.com
smtp_port = 25
```
However, when I try it again, I still get the same result. In the Apache error logs I still get this:


```
[error] [client 198.15.82.25] PHP Warning:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to localhost:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\r\n) in C:\\somedirectory\\class.smtp.php on line 105, referer: http://mypage/myscript.php[FONT=monospace][/FONT]
```
It still says localhost:25 instead of mail.mymailserver.com.

Did I miss a step? I restarted Apache already, by the way... so it shouldn't be that... Any help?

Thanks,

~j.


----------



## tomdkat (May 6, 2006)

Did you restart Apache after making the PHP ini file change?

Also, make sure *c:\\somedirectory\\class.smtp.php* doesn't have a mail server address hardcoded in it anywhere.

Peace...


----------



## TechGuy (Feb 12, 1999)

I'm not sure which CMS you're using, but make sure it doesn't have localhost in it's configuration somewhere.

(Sorry if this is the same thing that tomdkat is suggesting.  )


----------



## webzard (May 20, 2008)

Thanks for the replies! You were right, the "localhost" setting was in the CMS code so it was over-riding my php.ini setting. This is great! It works now, thank you all so much.


----------



## tomdkat (May 6, 2006)

Great! Glad you got it sorted out. 

Peace...


----------

