2012-09-19 35 views
1

尽管将php.ini配置为有效的send_from地址,但出现此错误。我知道这是有效的,因为它从松鼠邮件发送它时,但在用PHP发送邮件时,它将无法正常工作。该无效地址可能是指send_from地址。所以我不明白它是如何认为它是错的。这里是PHP代码:mail():SMTP服务器响应:550 hmailserver上的地址不是有效错误

$email="[email protected]"; 
$subject = "Your New Password"; 
$from="[email protected]"; 
$message = "Your new password is as follows: 

xxxxxxxxxxxxxxxxxxxxxxxxxxx 

This email was automatically generated."; 

     if(!mail($email, $subject,$message,$from)){ 
     echo ("error"); 
     }else echo "success"; 

,并在php.ini:

SMTP = localhost 

sendmail_from = [email protected] 
+0

您是否尝试将sendmail_from更改为实际有效的电子邮件地址? – rationalboss

+0

dayshare.local是否有dns + mx记录? – BugFinder

+0

我用[email protected]通过非php方法发送了电子邮件,所以推测这不是问题 – user1557515

回答

0

你需要引号和分号:

$email="[email protected]"; 
+0

而投下的票是因为? – BugFinder

+1

不知道为什么这是-1 - 你*做*需要这些引号... –

+0

可能是因为他应该得到一个不同的错误(不是550地址无效),像“解析错误:语法错误,意外” @'in ...“另外,该行缺少分号。 – rationalboss

2

mail()函数的第四个参数是不是简单的“来自”。在你的代码,你只透过电子邮件地址,而“发件人” - 第四个参数是其他邮件标题,所以你必须像这样格式化:

mail($email, $subject,$message,"From: [email protected]\r\nX-Mailer: PHP"); 

我增加了一个头作为例子。

+0

个好对象,但unfortunatlly仍然得到 – user1557515

+0

你检查你的错误日志文件的sendmail同样的问题? –

+0

没有我该怎么做? – user1557515

4

550 Delivery is not allowed to this address

This error means that the sender is trying to send an email to an address which he is not allowed to send to. This message is generated after hMailServer has checked the IP range settings. As an example, the default IP range configuration does not allow external users to send messages to other external users. This is to prevent people from using your server to send spam. So if an external user tries to send a message to another external user, he will get this message.

这就是你所得到的错误的含义。这是从hMailServer Documentation

如果以下方法可行,您可以尝试吗?

<?php 
mail('[email protected]','Test Email','This is a test email.',"From: [email protected]"); 
?> 

如果它不工作,那么它可能是由于你的hMailServer配置错误,你需要检查你的hMailServer Logs

+0

感谢您的代码,我得到了同样的问题,所以它可能是一个错误coniguration,但我不能为我的生命数字出来 – user1557515

0

这里是另一种解决方案 - WAMP send Mail using SMTP localhost


记住,每次,更改后的php.ini,

必须重新启动wamp(!!)

ps在php.ini中,我已经使用:

SMTP = localhost 
smtp_port = 25 
sendmail_from = [email protected] 

,或者如果奥尤着编辑的php.ini,试图插入你的PHP脚本,这些行。

ini_set("SMTP", "localhost"); 
ini_set("smtp_port", "25"); 
ini_set("sendmail_from", "[email protected]"); 
相关问题