使用PHP函数发送邮件时中继不允许的消息
我正在使用 wamp 服务器并尝试使用 PHP 函数 mail(' 发送电子邮件[电子邮件受保护]','我的主题','我的正文');
,
在 php.ini
中进行以下设置:
SMTP = 'ISP's SMTP server'
smtp_port = 25
但我收到消息:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Relaying not allowed. Please use SMTP Authentication.
如何解决这个问题?
I'm using wamp server and trying to send email with the PHP function mail('[email protected]','my subject','my body');
,
with the following settings in php.ini
:
SMTP = 'ISP's SMTP server'
smtp_port = 25
But I get the message:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Relaying not allowed. Please use SMTP Authentication.
How can this be solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 ISP 的邮件服务器不允许“中继”,这是一件好事,否则他们最终会传送大量垃圾邮件。
http://en.wikipedia.org/wiki/Open_mail_relay
为了能够使用 ISP 的邮件服务器,您需要首先使用用户名和密码进行身份验证。
您可以尝试破解 php.ini 行,如下所示:
SMTP = 'username:password@ISP's SMTP server address'
这不能保证有效,因为此选项需要非标准修改或在邮件服务器上设置的选项。
您的另一个选择是简单地运行您自己的本地代理邮件服务器,无需身份验证,然后将邮件直接发送到收件人的邮件服务器,或通过经过身份验证的连接发送到您的邮件服务器。
我不知道建议与 WampServer 一起使用什么,但与 WampDeveloper Pro 推荐的本地邮件服务器有:
您应该看到每一个的功能和要求。我相信其中之一可能会干扰MySQL(因为安装程序会尝试放置它自己的副本)。
Your ISP's mail servers do not allow "relaying", which is a good thing as otherwise they would end up moving a lot of spam.
http://en.wikipedia.org/wiki/Open_mail_relay
To be able to utilize your ISP's mail servers you need to authenticate first with a username and password.
You can try a hack of that php.ini line that goes like this:
SMTP = 'username:password@ISP's SMTP server address'
This is not guaranteed to work as this option requires a non-standard modification or option to be set on the mail server.
Your other option is to simply run your own local proxy mail server that requires no authentication, which will then either send the mail directly to the recipient's mail server, or via an authenticated connection to your mail server.
I don't know what is recommended to be used with WampServer, but with WampDeveloper Pro the recommended local mail servers are:
You should see the features and requirements of each one. I believe one of them can interfere with MySQL (as the installer will try to place its own copy of it).
ISPdomain.com SMTP 服务器可能会抱怨您的连接对于其反垃圾邮件规则而言过于基本。
The ISPdomain.com SMTP server is probably complaining that your connection is too basic for its anti-spam rules.
正如错误消息所示,您需要对该服务器使用 SMTP 身份验证。
使用 PHP 的内置 SMTP 功能无法实现这一点。
最简单的方法是使用预制的邮件程序类,例如 Swiftmailer。 这里是一个如何执行此操作的示例。
As the error message says, you need to use SMTP authentication for that server.
This is not possible using PHP's built-in SMTP capabilities.
The easiest way is to use a pre-made mailer class like Swiftmailer. Here is an example how to do it.