2011-09-01 67 views
-1

Possible Duplicate:
.NET SMTP Client - Client does not have permissions to send as this senderASP.NET MVC - SmtpClient - 客户端没有权限发送的该发件人

我有一个ASP.NET MVC3应用程序执行以下代码。

MailMessage message = new MailMessage("[email protected]", "[email protected]", "Test Message","Test Body"); 
EmailManager.Send(message); 

然后我有一个引用的DLL用于发送电子邮件。

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 server response was: 5.7.1 Client does not have permissions to send as this sender 

有趣的是,当我在我的Web应用程序中直接使用相同的代码时,电子邮件被正确发送。当通过引用的DLL调用凭据时,是否有原因存在?可能是因为它是静态的(或者不能在Web应用程序之外拾取证书?)。

+0

你有web.config中的smtp设置吗? –

+1

你为什么要创建另一个问题,像今天的其他问题:http://stackoverflow.com/questions/7269174/net-smtp-client-client-does-not-have-permissions-to-send-as-this-发件人? –

回答

1

这通常发生在SMTP服务器被锁定时。它可能有一个IP地址白名单,你的不是其中之一,或者你的地址不在授权出站域列表中。

相关问题