Jump to content

php.ini SMTP setting ignored


Recommended Posts

Hi

 

I have a local installation of Apache + PHP on my Windows 7 machine.

When setting the SMTP directive in the php.ini file to some remote server, the php server ignores it and instead still tries to access localhost as an SMTP server.

The remote server I am trying to use does exist, and it works on my other machine, but for some reason, even after several server and computer restarts it simply ignores the value I set.

It definitely is the correct php.ini file as it show it in the phpinfo() as the loaded configuration file and further, any other settings that I change in there are effective.

 

What could possibly cause this?

 

Thanks in advance

Link to comment
Share on other sites

Without seeing the error message, your code, or confirmation that the setting is syntactically correct (php.ini settings that contain invalid syntax do display as what they are set as but aren't actually used) best guess is that your code is not actually dependent on the php.ini SMTP setting, such as when you use one of the php mailer classes.

Link to comment
Share on other sites

I changed my php.ini setting from

SMTP = localhost

to

SMTP = some.smtp.server.net

 

My code is actually dependent on the SMTP setting, because I am using the mail() function on Windows and I don't have an SMTP server on my machine, so I get the error:

Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

 

My port setting I left at 25 and sendmail_path is commented out.

 

phpinfo() also shows my SMTP as localhost. And the value (and syntax) is exactly the same as on my other machine that is still running XP, where it works fine.

Link to comment
Share on other sites

Check your phpinfo() for "Configuration File (php.ini) Path" and make sure that it points to the file that you actually changed (sometimes you can end up with more than one php.ini). Did you restart Apache after changing it (that's required to make changes take effect).

Link to comment
Share on other sites

Oops, sorry my bad, I of course meant loaded configuration file, just copied the wrong one. Are you actually using the plain old mail function or are you, as suggested by PFMaBiSmAd, using a different mailer class. If the former what happens if you echo ini_get('SMTP'); just before calling it? If the latter I believe they generally have their own internal settings which can be changed in their configurations.

Link to comment
Share on other sites

What exact method did you use to install PHP? The .zip package, the .msi installer package, or one of the all in one xAMP packages?

 

I'm going to guess the .msi installer? If so, please be advised that the .msi installer is retarded, should not be used by anyone, and it places a bunch of setting in the Windows registry that override the php.ini settings.

Link to comment
Share on other sites

Well I installed PHP using the plain old Zip package.

 

I am using the plain old mail() function. I have reverted back to placing the php.ini file in the c:\windows directory and removing any PHPIniDir settings in the httpd.conf files. I have replaced the php.ini file with one I got from a wamp installation on my other machine which seems to work fine. I am currently trying to figure out the difference between the two ini files that might cause the problem.

 

However things are going difficult as a mere restart of the Apache server doesn't seem to always refresh the ini file for some reason.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.