【问题标题】:the server rejected one or more recipient addresses. the server response was 550 5.7.1 unable to relay服务器拒绝了一个或多个收件人地址。服务器响应为 550 5.7.1 无法中继
【发布时间】:2013-02-05 09:53:16
【问题描述】:

我正在使用我们公司的 SMTP 服务器发送邮件。当我向其他邮件(公司域外)发送邮件时遇到问题,返回错误:

"服务器拒绝了一个或多个收件人地址。服务器 响应为 550 5.7.1 无法中继”。

如果邮件在公司内部,则没有错误,邮件发送成功。我的 Web 应用程序托管在 IIS 中。

【问题讨论】:

    标签: asp.net iis smtpclient


    【解决方案1】:

    我会假设您的代码没有任何问题。我猜这是一个配置问题,即 SMTP 服务器配置为不向不属于您公司域的地址发送电子邮件。如果是这样,您需要与您的 Windows/网络团队核实,以确认在 SMTP 服务器级别应用的配置。

    【讨论】:

      【解决方案2】:

      我已经解决了这个问题。要使用此代码,您需要添加命名空间 Using System.Web.Mail;

      源代码:

      MailMessage mail = new MailMessage();
      
      mail.To = "yourfromemail@domain.com";
      
      mail.From = "yourtodomain@domain.com";
      
      mail.Subject = "Email test.";
      
      mail.Body = "Your body text here";
      
      mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");   //basic authentication
      
      mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
      
      mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret");       //set your password here
      
      SmtpMail.SmtpServer = "127.0.0.1";  
      
      SmtpMail.Send( mail );
      

      //你需要将localhost地址添加到IIS管理器。 转到 IIS 管理器 -> 默认 SMTP 服务器 -> 属性 -> 访问 -> 中继 -> 仅从下面的列表中允许 -> 添加 -> 127.0.0.1 -> 单击确定

      【讨论】:

        猜你喜欢
        • 2015-10-14
        • 2018-02-05
        • 2017-10-14
        • 2015-03-06
        • 2018-08-02
        • 2017-11-24
        • 1970-01-01
        • 1970-01-01
        • 2011-09-09
        相关资源
        最近更新 更多