如何解决php mail错误问题
时间:2021-11-02 来源:互联网
今天PHP爱好者为您带来php mail错误的解决办法:1、在smtp服务的中继选项中添加本机IP地址;2、在网关做个端口映射,把25端口映射到本机即可。希望对大家有所帮助。
本文操作环境:Windows7系统、PHP7.1版、DELL G3电脑
如何解决php mail错误问题?
php的mail()函数出错的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phpinfo</title>
</head>
<body>
<?
$to = "[email protected]";
$subject = "php-Mail";
$msg = "I completely understand SMTP servers now!";
$headers = "From: [email protected]/r/nReply-To: [email protected]";
mail("$to", "$subject", "$msg", "$headers");
echo "finished!";
?>
</body>
</html>
出现的错误:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [email protected] in C:/webserver/htdocs/www/mail.php on line 14
php.ini配置情况
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]
已经安装了windows自带的smtp服务
找了好久才发现需要在smtp服务的中继选项中添加本机IP地址
虚拟服务器->属性->访问->中继
选择"仅以下列表"=>"单台计算机"=>添加127.0.0.1的本地地址
程序没有出现问题,但收件箱中没有立即收到信息.
没有收到是因为我的机子是在内网中,不能把邮件发送到外网.
解决方法:
在网关做个端口映射,把25端口映射到本机.或者本机有公网IP.
以上就是如何解决php mail错误问题的详细内容,更多请关注php爱好者其它相关文章!
-
永劫无间多少钱一个红 2024-12-20
-
永劫无间多少钱开一个箱子 2024-12-20
-
阿瑞斯病毒2火铳弹药怎么获得?阿瑞斯病毒2火铳弹药获得方法 2024-12-19
-
阿瑞斯病毒2哈士奇在哪?阿瑞斯病毒2哈士奇获得方法 2024-12-19
-
寻道大千反击流阵容推荐 2024-12-19
-
和平精英性别怎么换?和平精英性别转换方法 2024-12-19