Why is this PHP error referencing localhost?

I am running XAMPP on my local computer and on the server in the office. Both Windows machines.

I am writing code that I use mail()to send email from a form. By default, it uses sendmail.exe(which comes with XAMPP) to send email . In all cases, mail is actually sent through a third computer, which is the Exchange server.

On my local machine, PHP can send mail just fine. On the server, after submitting the form, I get this error:

Warning: mail () [function.mail]: Failed to connect to the mail server in "localhost" 25, check "SMTP" and "smtp___port" in php.ini or use ini_set () in

... then my file name.

I do not understand why it refers to "localhost". Nowhere in php.ini or sendmail.ini "localhost" is used - I use the name of the mail server. The SMTP information used on both machines is the same.

As far as I can tell, in both environments there is everything important:

  • Php.ini files are identical
  • Sendmail.ini files are identical
  • Both machines have the same version of XAMPP installed.
  • The same script batches will run on both machines and successfully send email through sendmail.exe

I stopped and ran Apache several times to make sure it was using updated configuration files.

When I get the error message above, I notice that the sendmail.exe file does not create a log file, which makes me think that it never starts.

What am I missing?

solvable

, , c:\xampp\php\php.ini, c:\xampp\apache\bin\php.ini. , , - .

php_info(), , , . ! .

+3
3

phpinfo() , :

  • PHP script php.ini
  • , SMTP ini ( phpinfo) .
+2

:

ini_set("SMTP","smtp.example.com" );
ini_set('sendmail_from', 'user@example.com'); 
+1

I also had to do this - you need to send sendmail.ini:

Your sendmail.ini should be located in the folder C: \ xampp \ sendmail \ sendmail.ini.

You only need to worry about three variables here:

1.smtp_server
2.auth_username
3.auth_password

Details here: Send mail and xampp

Bill h

0
source

Source: https://habr.com/ru/post/1715127/


All Articles