2017-06-21 34 views
0

同一個ASP.NET MVC 4網站,同一個郵件發送代碼。從AccountController發送電子郵件不再適用於其他所有控制器。郵箱不可用。服務器的迴應是:5.7.1無法中繼

下面是我從的AccountController行動得到錯誤:

Cannot send e-mail from [email protected] to [email protected] 
Exception: Mailbox unavailable. The server response was: 5.7.1 Unable to relay. 
mail.domain.com, SMTPSVC/mail.domain.com, 25, 

我應該怎麼檢查?它工作多年,但最近的Windows Server 2008/Exchange 2010更新不再有效。

MailMessage message = new MailMessage(fromAddress, toAddress) 
{ 
    Subject = subject, 
    Body = body, 
    IsBodyHtml = isHtml 
}; 

try 
{ 
    smtpClient.Send(message); 

    string errorMsg = "Sending e-mail from " + fromAddress.Address + " to " + originalAddresses[i]; 
    errorMsg += Environment.NewLine; 
    errorMsg += smtpClient.Host + ", " + smtpClient.TargetName + ", " + smtpClient.Port + ", " + smtpClient.ClientCertificates + ", " + smtpClient.EnableSsl + ", " + smtpClient.UseDefaultCredentials + ", " + smtpClient.Timeout; 

    sw.WriteLine(errorMsg) 
} 
catch (Exception ex) 
{ 
    string errorMsg = "Cannot send e-mail from " + fromAddress.Address + " to " + originalAddresses[i] + ", " + "Exception: " + ex.Message + 
           (ex.InnerException != null ? ", " + ex.InnerException.Message : string.Empty); 
    errorMsg += Environment.NewLine; 
    errorMsg += smtpClient.Host + ", " + smtpClient.TargetName + ", " + smtpClient.Port + ", " + smtpClient.ClientCertificates + ", " + smtpClient.EnableSsl + ", " + smtpClient.UseDefaultCredentials + ", " + smtpClient.Timeout; 

    sw.WriteLine(errorMsg); 

    return false; 
} 

任何想法我應該檢查什麼? AccountController有什麼特別的我應該關心的?控制器操作屬性[RequireHttps]是否涉及一些?

謝謝。

EDIT1:

這是我們的Exchange 2010中設置(請注意,我們可以從其他ASP.NET MVC控制器發送相同電子郵件):

https://practical365.com/exchange-server/how-to-configure-a-relay-connector-for-exchange-server-2010/

EDIT2:

我錯了,問題不是ASP.NET M VC控制器相關但與電子郵件地址域相關。我發現,我們所有時間都包含一個不屬於我們公司域名(外部互聯網)的電子郵件地址,我們會得到上述錯誤。所以現在的問題是:爲什麼Exchange 2010接收連接器現在無法將電子郵件通知發送到外部Internet?

+1

是不是隻是您可能需要使用SMTP服務器進行身份驗證?由於您試圖將郵件發送到不同的域(domain.com!= microsoft.com)? – kayess

+0

檢查IIS管理器上的中繼限制設置=>默認SMTP虛擬服務器=>屬性=>訪問=>中繼限制,在那裏添加您的公共IP地址,然後在身份驗證訪問控制設置中標記匿名訪問和集成Windows身份驗證。同時檢查用於發送郵件的現有'NetworkCredential'。 –

+0

@ kayess:我們確實從所有其他控制器發送併發送了電子郵件。 – abenci

回答

0

服務器場更改了我們服務器的傳出IP地址,這阻止了包含未在我們公司域中的收件人的所有電子郵件。將新的傳出IP地址添加到Properties->Network->Receive mail from remote servers that have these IP addresses下的Exchange 2010接收連接器解決了此問題。

相關問題