문제

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