简体   繁体   English

SMTP服务器响应:550 5.7.1无法中继 - 将电子邮件发送到非公司地址

[英]SMTP server response: 550 5.7.1 Unable to relay in - Sending email to a non-company address

Here is my code: 这是我的代码:

<?php
mail('myemail@gmail.com','Test','Test');
?>

When sending to a non-company address, I get the following error: 发送到非公司地址时,我收到以下错误:

Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay in C:\inetpub\wwwroot\internal_tools\include\mail.php on line 2

When switching the email address to my work email, it works just fine. 将电子邮件地址切换为我的工作电子邮件时,它可以正常工作。 My PHP.ini looks fine, too: 我的PHP.ini也很好看:

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
SMTP = PCMAIL1.mycompany.com
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = no-reply@mycompany.com

Even have the site set up in IIS7: 甚至在IIS7中设置了站点:

Any ideas? 有任何想法吗?

To prevent abuse for sending spam , many email servers require that the client be authenticated as a legitimate user before relaying mail (forwarding it to the recipient's email server). 为防止滥用发送垃圾邮件 ,许多电子邮件服务器要求在转发邮件(将其转发到收件人的电子邮件服务器)之前将客户端验证为合法用户。 You have specified credentials in IIS; 您已在IIS中指定凭据; however, PHP does not make use of them. 但是,PHP没有使用它们。

Here are your options: 以下是您的选择:

  • Instead of the mail() function, use one of the existing PHP mailer libraries that supports SMTP authentication (PEAR Mail, phpmailer, Swift Mailer, etc. ). 而不是mail()函数,使用支持SMTP身份验证的现有PHP邮件程序库之一(PEAR Mail,phpmailer,Swift Mailer )。
  • Install and configure msmtp or one of the alternatives (here's how to make msmtp work with PHP ). 安装和配置msmtp或其中一个备选方案(这里是如何使msmtp与PHP一起工作 )。 PHP will execute the program, which does support SMTP authentication, whenever it has to send a message if you set sendmail_path accordingly. 如果您相应地设置sendmail_path ,PHP将执行该程序,该程序支持SMTP身份验证。
  • Change the mail server's configuration to allow relaying mail from the web server's IP address. 更改邮件服务器的配置以允许从Web服务器的IP地址中继邮件。

You need to check your Smtp provider's policy. 您需要检查您的Smtp提供商的政策。 Or you need to check your Smtp server configuration (if this server deliver the emails directly) 或者您需要检查您的Smtp服务器配置(如果此服务器直接发送电子邮件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM