我需要在我們的應用程序中實施「電子郵件支持」部分。因此,電子郵件地址將爲[email protected],地址爲最終用戶的電子郵件地址(最終用戶的電子郵件地址可能位於相同的域或其他域,如[email protected]或用戶@ gmail.com)。電子郵件支持部分的用戶地址爲「發件人地址」
在我使用驗證管理員帳戶的詳細信息(用戶名和密碼)
System.Net.NetworkCredential("[email protected]", adminpassword);
而且我使用的主機地址的電子郵件應用程序「mail.mydomain.com」 問題是我正在以下錯誤:
「Mailbox unavailable. The server response was: From address must match authenticated address」 error message.
是否有可能用正確的發件人的電子郵件地址發送電子郵件(從地址的用戶)
我的代碼示例是
message.To.Add(「[email protected]」);
message.From = new MailAddress(「[email protected]」);
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential([email protected], adminpassword);
smtp.EnableSsl = false;
object usrtkn = message;
smtp.Send(message);
很高興看到你對這個場景中'user'和'system'應該扮演的角色有相同的解釋。 :-) –
@KarlAnderson:同意。我經常看到有人試圖從審計線索中刪除軟件,並使其看起來像用戶直接做所有事情,但事實並非如此。 (http://publicvoidlife.blogspot.com/2012/05/case-for-service-accounts.html)應用程序本身就是後端服務的用戶,應該這樣對待。 – David