如何使用来自localhost的PHP中的mail()函数发送邮件[复制]

This question already has an answer here:

I am using a mail() function to send mail in PHP from localhost but it is not working.

Sending mail from localhost is my primary concern. Please guide me a way to achieve the same.

</div>

You won't have SMTP server installed by default so you can't send emails from localhost directly. Either you can set up SMTP server on local or use third party SMTP servers. Have a look at

http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp

which gives you insight about how to send mail from localhost using third party SMTP server.

Here's the some of the method that might be help you :

Method 1 https://stackoverflow.com/a/16814318/2377343

Method 2 http://thephpcode.blogspot.com/2009/03/setting-up-local-mail-smtp-pop3-imap.html

Method 3 http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/

Method 4 Configure wamp server to send email

Method 5 http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

It is configured to use localhost:25 for the mail server.

The error message says that it can't connect to localhost:25.

Therefore you have two options:

  1. Install / Properly configure an SMTP server on localhost port 25
  2. Change the configuration to point to some other SMTP server that you can connect to