在PHP中使用脱机服务器

I'm having problems using the mail command in PHP through an offline server. I've used the mail(to, subject, body) function but the mail wasn't sent to the address. Should I be online?

No, your problem is that you have no SMTP server installed. I suggest you to check on of these:

After successfull setting it up, you'll need to configure your php.ini too, to point at the SMTP you are using.


Or instead of creating your own, you can google how to use someone else's SMTP. The choice is yours.

if you are running code from local server then mail function will not send mail. Mail function need live mail server. You can use smtp mail to send mail from local server.