Failed to connect to the mail server on the localhost port 25

I keep getting this error when I try to send an email to PHP:

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:\wamp\www\dressoholic\register.php on line 50 

my php.ini looks like this:

 [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = you@yoursite.com 

I use my laptop as a server. What am I doing wrong? Thank.

+43
php email smtp
Dec 26 '10 at 2:10
source share
7 answers

You need to start the mail server locally. If it is Unix, enable sendmail. If it is Windows, install Simple Mail Transfer Server (not sure if this name is correct) component II. For example. for Windows 2003, follow these steps: http://msdn.microsoft.com/en-us/library/8b83ac7t.aspx

+25
Dec 26 '10 at 2:13
source share

In windows, almost all AMPP packages (Apache, MySQL, PHP, PHPmyAdmin) do not include a mail server (but almost all bare Linux have!). Thus, when using PHP under windows, you need to configure your mail server!

Imo the best and easiest tool ist this: http://smtp4dev.codeplex.com/

SMTP4Dev is a simple single-file mail server that collects letters sent to it (therefore, it does not send mail, but simply saves them for development). The perfect tool.

+19
May 14 '13 at 3:11
source share

To send mail, use the php mail function. But the email function requires an SMTP server to send emails. we should mention the SMTP host and SMTP port in the php.ini file. After successfully setting up the SMTP server, letters will be sent successfully sent via php scripts.

+17
Sep 16 '12 at 10:11
source share

If you run your application only on localhost, and it has not yet been implanted, I believe that sending a message with this help is very difficult.

As soon as you post your application online, I believe that this problem should be automatically resolved. Bbut, I think ini_set() will help you change the values ​​in php.ini at runtime.

+6
17 Sep '12 at 11:10
source share

First of all, you should not use SMTP on your local host, if you change this localhost entry to the MTA DNS name of your ISP (which will allow you to forward mail), it will work right away, so you don’t need to communicate with your own mail service. Just try using your suppliers' SMTP servers, it will work right away.

+5
Sep 21 '12 at 7:32
source share

The PHP mail function can send email in two scenarios:

but. Try sending email through the unix sendmail program. In linux, the sendmail program will be executed, put all the parameters in sendmail and that’s it.

OR

b. Connect to the mail server (using the smtp protocol and host / port / username / pass from php.ini) and try sending an email.

If php cannot connect to the email server, it will warn (and you see this work in your logs). To solve the problem, install the smtp server on the local computer or use any available server. How to configure / configure smtp, you can find on php.net

+3
Sep 19 '12 at 18:13
source share

php allows you to send emails from localhost, but this problem will be solved if you put the project on the server. or if you want to check if my email is sent or not, you need to download smtp4dev and install it. This will give you a message if your email is sent successfully or there is a problem in your code.

0
Sep 28 '17 at 15:10
source share



All Articles