search
Homephp教程PHP源码php的mail()函数出错的问题

<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!";
?>



出现的错误:
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配置情况

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

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

已经安装了windows自带的smtp服务

找了好久才发现需要在smtp服务的中继选项中添加本机IP地址

虚拟服务器->属性->访问->中继
选择"仅以下列表"=>"单台计算机"=>添加127.0.0.1的本地地址

程序没有出现问题,但收件箱中没有立即收到信息.

没有收到是因为我的机子是在内网中,不能把邮件发送到外网.

解决方法:在网关做个端口映射,把25端口映射到本机.或者本机有公网IP.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment