Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP.INI SMTP server.domain.com but in phpinfo() it says localhost

Status
Not open for further replies.

mkoponick

Programmer
Feb 3, 2005
8
US
Hello,

I'm still learning PHP, and have run into a but of a problem.

I have setup Apache 2.x and PHP 4.x on a Windows 2000 server. I have an application that sends email to users after they have filled out a form.

The problem that I am seeing is that is errors when it tries to send mail, saying it can't because it can't find the email server. I have set my php.ini file to the appropriate email server, which it can connect to manually (telnet server.domain.com 25). However when I check the phpinfo(), it says that the SMTP is set to localhost. phpinfo() also says that it is finding the php.ini file in the correct place,(C:\WINNT\php.ini).

I have installed the same application on a Linux server that is setup with the same revisions of PHP and Apache, and does not have any issues with sending mail. I believe the reason is that the Linux server has sendmail configured, and sending e-mail to "localhost" is an OK thing.

Has anyone else seen an issue like this??

Thanks in advance.

Mike
 
Are both the local value and the master value "localhost"?

If PHP is running as an Apache module, was Apache restarted after the change to php.ini?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
The only setting I know of is in the c:\winnt\php.ini file. Is there another?

Yes, I have tried to start/restart apache after making the changes.

Thanks!!

Mike
 
may be stating the blindingly obvious:

under the [mail function] heading

+ make sure that the sendmail_path parameter in the php.ini file is commented out (put semicolon before).

25+ make sure that there is an SMTP parameter. i always set this to an actual IP address. have not tried with DNS resolution. have you tried using just an IP address?

+ make sure that the smtp_port parameter is set to 25.

lastly, although you may be able to telnet to a port this does not mean that the mail server will accept mail from it. you may have parameters set within the mail server that prohibits incoming smtp relay from various IP addresses, domains and or unknown users (have you set the sendmail_from parameter to a known address?) which mail server are you using? you should be able to check the server's logs to find out whether this is the cause.

last of all, and if nothing else works - have you considered installing a small smtp server on the win 2000 box?

Justin

 
Justin,

Thanks for the suggestions. I failed to add in the portions of my PHP.INI file that I changed. Here is a view of my PHP.INI file:

[mail function]
; For Win32 only.
SMTP = 192.168.xxx.xxx
;(removed to protect the innocent)
smtp_port = 25

; For Win32 only.
sendmail_from = mike@mydomain.com
; For Unix only. You may supply arguments as well(default: "sendmail -t -i").
;sendmail_path =

Whatever I change in the php.ini file, phpinfo() always say localhost for the SMTP server (Local and Master). Looking at the docmentation I see that php will look in the C:\WINNT for php.ini, which is where I have it. phpinfo() also says that is where php.ini resides. I made sure there are no other php.ini files.

I checked our e-mail server as a sanity and found that it will accept e-mail from the IP address of the server in question.

As for a SMTP server on the windows machine. That's a great idea but it's one more thing I would need to manage. I would think that the options in php.ini should work.

Hopefully, this will be one more step towards resolving this issue.

Again, thanks in advance.

Mike
 
Did you restart your web server after making the changes to PHP.INI?
 
Yes. The webserver has been restarted everytime I have made a change to PHP.

Thanks!

Mike
 
are you running php as an apache module or as a cgi?
 
Currently, it is running as a module.

Thanks!


Mike
 
could you post the httpd.conf section that loads php's module?

there should be a line looking something like one of these:
Code:
#LoadModule php4_module php4/mod_php4_ap2.so
 LoadModule php5_module "c:/opensa/apache2/php5/php5apache2.dll"

and a line with the PHPINIDir parameter.

these are the lines to copy if you can.

thanks
Justin
 
Justin,

Here is the PHPINIDIR:

PHPIniDir "C:/php"

httpd.conf:

LoadFile "c:/php/php4ts.dll"

LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php



The above DLL's are in the C:\php directory.

Thanks!

Mike
 
then, I believe, that is your issue. earlier in the posts you said you were editing the php.ini in the c:\winnt directory.

you should instead be editing the php.ini in the c:\php directory (or change the phpINIDir to the winnt directory.

does that fix things? if it can't find the php.ini file in the directory then I believe that php loads with its defaults.

does that fix it?
Justin
 
Justin,

I went through that once before. After looking at a php.ini file in the C:\PHP directory, I see that is the same. Just for insurance, I copied the php.ini in the c:\WINNT and the c:\PHP directories.

Also, just to add to the mix, I ran the following:

C:\>php -v
PHP: Error parsing c:\PHP\php.ini on line 13
PHP 4.3.10 (cgi-fcgi) (built: Dec 14 2004 17:47:59)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

C:\>php -v -c \winnt
PHP: Error parsing C:\winnt\php.ini on line 13
PHP 4.3.10 (cgi-fcgi) (built: Dec 14 2004 17:47:59)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


It just happens that line 13 is the PHPINIDR statement.

Should this reside somewhere else in the php.ini file?

Thanks!

Mike
 
i'm not sure what the phpinidir statement is within php.ini. i've never come across that before! usually the phpinidir is in the httpd.conf file.

what version of apache are you using? i will do some research about php->apache interaction.
 
OK. I FINALLY figured this thing out thanks to Justin.

The PHPINIDIR= state needs to be in the HTTPD.CONF file, after you load the modules for PHP.

The PHPINIDIR= statement doesn't belong in the php.ini file.

NOW, phpinfo() reads the correct settings for me system

Thanks to all who responded!

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top