Php mail () function error-PHP source code

Source: Internet
Author: User
Ec (2); & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML1.0TransitionalEN & quot; www. w3.orgTRxhtml1DTDxhtml1-transitional. dtd & quot; & gt; & lt; htmlxmlns & quot; www. w script ec (2); script





Phpinfo


$ To = "atoat@sina.com ";
$ Subject = "php-Mail ";
$ Msg = "I completely understand SMTP servers now! ";
$ Headers = "From: atoat@163.comrnReply-To: atoat@163.com ";
Mail ("$ to", "$ subject", "$ msg", "$ headers ");
Echo "finished! ";
?>



Error:
Warning: mail () [function. mail]: SMTP server response: 550 5.7.1 Unable to relay for atoat@sina.com in C: webserverhtdocswwwmail. php on line 14

Php. ini configuration

[Mail function]
; For Win32 only.
SMTP = localhost
Smtp_port = 25

; For Win32 only.
Sendmail_from = atoat@163.com

You have installed the smtp service that comes with windows.

It took a long time to find that the local IP address needs to be added to the smtp service relay option.

Virtual Server-> properties-> access-> Relay
Select "only the following list" => "single computer" => Add a local address of 127.0.0.1

The program has no problem, but the inbox does not receive the message immediately.

I did not receive the email because my machine is in the internal network and cannot send the email to the Internet.

Solution: Create a port ing in the gateway to map port 25 to the local machine, or the local machine has a public IP address.

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.