【问题标题】:Send Email using windows credentials of the application users使用应用程序用户的 Windows 凭据发送电子邮件
【发布时间】:2014-04-29 14:16:44
【问题描述】:

我正在开发一个发送电子邮件的应用程序,其中一个组件使用用户的 Windows 凭据发送电子邮件。

string SMTP = "smtp.corp.com";
MailMessage msg = new MailMessage(Sender, Recipient, Subject, Body);
SmtpClient smtpclient = new SmtpClient(SMTP, 25);
smtpclient.EnableSsl = false;
smtpclient.UseDefaultCredentials = true;
msg.IsBodyHtml = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s,X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
smtpclient.Send(msg);

此代码在本地机器上运行良好,但在服务器上部署后出现错误

Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender

因为在这种情况下发件人是:

string Sender = HttpContext.Current.User.Identity.Name+"@corp.com";

谢谢

【问题讨论】:

标签: c# asp.net email


【解决方案1】:

在您的本地计算机上,您的应用程序以管理员身份运行,因此拥有发送电子邮件的完全权限。所以它可以在你的本地机器上运行

但是在服务器上,如果您的应用程序没有以管理员身份运行,它就没有发送电子邮件的权限。所以它在你的服务器上不起作用。

所以解决方案是,授予您的应用程序权限。

更多详细信息请查看此链接: http://social.technet.microsoft.com/Forums/exchange/en-US/e763de97-88a1-494d-9841-4f3a466b5604/exchange-550-571-client-does-not-have-permissions-to-send-as-this-sender

【讨论】:

    【解决方案2】:

    由于访问权限不足,您会收到此错误,在这种情况下,您必须首先提供它们。

    要么你有变化像

    smtpclient.UseDefaultCredentials = false;
    smtpclient.Credentials = new System.Net.NetworkCredential("username", "password");
    

    或在 Web.Config 中进行更改,如

     <mailSettings>
     <smtp from="SystemAdmin@domain.do">
      <!--network host="EXCH-SERVER" port="25" userName="userName" password="password"         
      defaultCredentials="false" /-->                                 
     <network host="EXCH-SERVER" port="25" />
     </smtp>
     </mailSettings>
    

    请看here

    希望这会对你有所帮助。

    【讨论】:

      【解决方案3】:

      在服务器上部署后

      它在服务器上以哪些 Windows 用户身份运行?如果这是在 IIS 中运行的 ASP.Net,那么它使用的是您在应用程序池中设置的任何身份......这是什么?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-20
        • 1970-01-01
        相关资源
        最近更新 更多