我正在開發一個發送電子郵件的應用程序,它具有使用用戶的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";
感謝
的可能重複[.NET SMTP客戶端 - 客戶端沒有權限發送的該發件人(http://stackoverflow.com/questions/7269174/net-smtp-client-client-does-not-have-權限發送作爲這個發件人) –
這有幫助嗎? http://stackoverflow.com/questions/7269174/net-smtp-client-client-does-not-have-permissions-to-send-as-this-sender –