Вопрос

I try to use mail function to send e-mail in php when i use my code i have error message

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

This is the line for error message

$success = mail($mailto, $emailSubject, $body, $headers);

how to solve it , help please

Это было полезно?

Решение

The problem is that you are not running an incoming mail server (listening on SMTP port 25) on your machine (where the PHP script is executed), which it happens to connect to by default.

If you can install a SMTP server locally easily, e.g. in Linux by installing a "sendmail" package, you can solve it like that.

If you don't want to run such a server, you must at least modify your php.ini to set a SMTP server of your internet or mail provider instead. Search for smtp in the .ini file and fill the variables accordingly.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top