2014-04-29 29 views
0

我正在開發一個發送電子郵件的應用程序,它具有使用用戶的Windows憑據發送電子郵件的組件之一。使用應用程序用戶的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";

感謝

+0

的可能重複[.NET SMTP客戶端 - 客戶端沒有權限發送的該發件人(http://stackoverflow.com/questions/7269174/net-smtp-client-client-does-not-have-權限發送作爲這個發件人) –

+0

這有幫助嗎? http://stackoverflow.com/questions/7269174/net-smtp-client-client-does-not-have-permissions-to-send-as-this-sender –

回答

1

在您的本地機器上,您的應用程序ru n作爲管理員,因此具有發送電子郵件的完全權限所以它可以在你的本地機器上運行

但是在服務器上,如果你的應用程序沒有以管理員身份運行,它將不具有發送電子郵件的權限。所以它不適用於你的服務器。

所以解決方案是,給你的應用程序的許可。

更詳細的信息,請訪問以下鏈接: 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

0

由於無法獲得充分的權利,你在,你必須爲他們提供在首位這種情況下,出現此錯誤。

要麼你有一個像

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

變化或使Web.Config中更改,如

<mailSettings> 
<smtp from="[email protected]"> 
    <!--network host="EXCH-SERVER" port="25" userName="userName" password="password"   
    defaultCredentials="false" /-->         
<network host="EXCH-SERVER" port="25" /> 
</smtp> 
</mailSettings> 

請看看here

希望這會幫助你。

0

是它運行的Windows用戶作爲服務器上的服務器

上部署後?如果這是在IIS內運行的ASP.Net,那麼它將使用您在應用程序池中設置的任何身份....這是?

相關問題