ASP.NET MVC - SmtpClient - Client does not have permissions to send as this sender [duplicate]
Possible Duplicate:
.NET SMTP Client - Client does not have permissions to send as this sender
I have an ASP.NET MVC3 application which performs the following code.
MailMessage message = new MailMessage("none@none.com", "none@none.com", "Test Message","Test Body");
EmailManager.Send(message);
I then have a referenced DLL which is used for sending emails.
public static class EmailManager
{
#region Public Methods
public static void Send(MailMessage message)
{
if (ApplicationConfiguration.Instance.EnableEmail)
{
var client = new SmtpClient(ApplicationConfiguration.Instance.SmtpAddress);
client.UseDefaultCredentials = true;
client.Send(message);
开发者_高级运维}
}
#endregion
}
The issue I have is that when I send the email I get the following error: Mailbox unavailable.
The server response was: 5.7.1 Client does not have permissions to send as this sender
The interesting thing is that when I use the same code directly within my Web app, the email is sent correctly. Is there a reason why the credentials are not being picked up when being called via the referenced DLL? Possibly because it is static (or can credentials not be picked up outside of the web application?).
This usually happens when the SMTP server is locked down. It probably has a whitelist of IP addresses and your's isn't one of them, or your to address is not in the list of authorised outbound domains.
精彩评论