php mail(): SMTP 服务器响应: 550 The address is not valid error on hmailserver
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12495509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mail(): SMTP server response: 550 The address is not valid error on hmailserver
提问by user1557515
I am getting this error despite configuring php.ini to a valid send_from address. I know it is valid because it works when I send it from squirrel mail but when sending mail in php it will just not work. the invalid address presumably refers to the send_from address. so I can't see how it can think it's wrong. here is the php code:
尽管将 php.ini 配置为有效的 send_from 地址,但我仍收到此错误。我知道它是有效的,因为当我从 squirrel 邮件发送它时它可以工作,但是当在 php 中发送邮件时它就行不通了。无效地址大概是指 send_from 地址。所以我看不出它怎么会认为这是错误的。这是php代码:
$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";
and in php.ini:
并在 php.ini 中:
SMTP = localhost
sendmail_from = [email protected]
回答by rationalboss
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.
550 不允许送货到这个地址
此错误意味着发件人正在尝试向他不允许发送的地址发送电子邮件。此消息是在 hMailServer 检查 IP 范围设置后生成的。例如,默认 IP 范围配置不允许外部用户向其他外部用户发送消息。这是为了防止人们使用您的服务器发送垃圾邮件。因此,如果外部用户尝试向另一个外部用户发送消息,他将收到此消息。
That is the meaning of the error you are getting. This is from the hMailServer Documentation.
这就是你得到的错误的含义。这是来自hMailServer 文档。
Can you try if the following will work?
你能试试下面的方法吗?
<?php
mail('[email protected]','Test Email','This is a test email.',"From: [email protected]");
?>
If it doesn't work, then it's probably due to a misconfiguration in your hMailServer and you would need to check your hMailServer Logs.
如果它不起作用,则可能是由于您的 hMailServer 配置错误,您需要检查您的hMailServer Logs。
回答by venky1893
回答by Gerald Schneider
The 4th parameter of the mail()function is not plain "from". In your code, you are only passing the email address without "From: " - The fourth parameter is for additional mail headers, so you have to format it like this:
mail()函数的第四个参数不是简单的“from”。在您的代码中,您只传递没有“发件人:”的电子邮件地址 - 第四个参数用于附加邮件标头,因此您必须将其格式化为:
mail($email, $subject,$message,"From: [email protected]\r\nX-Mailer: PHP");
I added another header as an example.
我添加了另一个标题作为示例。
回答by BugFinder
回答by T.Todua
here is another solution - WAMP send Mail using SMTP localhost
这是另一个解决方案 - WAMP 使用 SMTP localhost 发送邮件
KEEP IN MIND, everytime, after You change php.ini,
请记住,每次更改 php.ini 后,
you must restart wamp (! ! !)
你必须重新启动wamp(!!!)
p.s. in php.ini, i have used:
ps 在 php.ini 中,我使用过:
SMTP = localhost
smtp_port = 25
sendmail_from = [email protected]
or if oyu cant edit php.ini, try to insert these lines in your php script.
或者如果 oyu 无法编辑 php.ini,请尝试在您的 php 脚本中插入这些行。
ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
ini_set("sendmail_from", "[email protected]");

