Same ASP.NET MVC 4 website, same mail send code. Sending e-mail messages from AccountController is not working anymore, from all the other controllers it is.
Here is the error I get from AccountController actions:
Cannot send e-mail from noreply@domain.com to bill@microsoft.com
Exception: Mailbox unavailable. The server response was: 5.7.1 Unable to relay.
mail.domain.com, SMTPSVC/mail.domain.com, 25,
What should I check? It worked from years but with a recent Windows Server 2008 / Exchange 2010 update is not working anymore.
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;
}
Any idea of what should I check? Has AccountController something special I should care about? Is the [RequireHttps]
controller action attribute somewhat involved?
Thanks.
EDIT1:
Here are our Exchange 2010 settings (please note that we can send the same e-mail message from other ASP.NET MVC controllers):
EDIT2:
I was wrong, the problem is not ASP.NET MVC controller related but e-mail address domain related. I discovered that the all the times we include an e-mail address that doesn't belong to our company domain (the outer internet) we get the error above. So now the question is: why the Exchange 2010 Receive Connector is now unable to send e-mail notification to the outer internet?