简体   繁体   中英

Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port”, XAMPP for WIndows XP

I am running a XAMPP server on Windows XP. Allegedly XAMPP automatically prepares a mail server.

This is the code I am using:

$cimzett = 'ledit4@gmail.com';
...
mail($cimzett, $targy, $uzenet, 'From:'.$email);

( $cimzett means "to", $targy is subject, $uzenet is message in Hungarian) but in the browser appling PHP it sends me this message:

I get this error message:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\PHP\alien.php on line 50

I tried to use set_ini() function too, but I got the same message.

Maybe the security properties of XAMPP does not allow me send an email to gmail.com?

I use PHP Version 5.3.5 and

SMTP localhost localhost smtp_port 25 25

are the settings reported by phpinfo();

I suspect the mail server is not working properly. What do you think?

Windows does not by default have an SMTP server installed. XAMPP won't install one for you either. If there IS one installed, then it's not running, because "connection refuse" on port 25 means nothing's there listening for email.

XAMPP will also not disable connections to external mail servers. However, Windows firewalls and/or some ISPs will (my isp does not allow external smtp connections as an anti-spam measure).

May be you should setup mail submitting as external account, your gmail one for example. more info here: Authentication php mail

Well if you want to do it anyway in your local machine, try installing IIS and configure the SMTP server from there. Remember this process is only for SMTP, you dont have to change existing installation of Apache and PHP. For more details,here is the link http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true

After following steps, the mail will be saved as a file in wwwroot directory. You may need to make further research on this, but you can take this solution as a starting point.

hope this helps

You will need an additional SMTP Server Application because Xampp doesn't support it. Download "Post Cast Server" version > 2. Goto tools -> Settings -> System -> SMTP server and set Host name as localhost server port as 25. And run the application minimized. It will definitely work because it has worked out for me when I was facing the same problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM