IT干货网

如何解决php mail错误

cyq1162 2023年02月01日 编程设计 32 0

1、在smtp服务的中继选项中添加本机IP地址。

2、在网关做个端口映射,把25端口映射到本机即可。

php的mail()函数出错的问题

$to = "atoat@sina.com"; 
$subject = "php-Mail"; 
$msg = "I completely understand SMTP servers now!"; 
$headers = "From: atoat@163.com/r/nReply-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:/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 = atoat@163.com

本文参考链接:https://www.yisu.com/zixun/616191.html
评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

php中如何使用rand()函数