2012-06-24 115 views
1

我嘗試使用亞馬遜SES服務發送電子郵件。我的代碼是從他們的documantation採取:asp.net代碼和郵件通過亞馬遜發送SES

public static void SendWithSMTP(string username, string password, string host, int port) 
{ 
    using (var client = new System.Net.Mail.SmtpClient(host, port)) 
    { 
     client.Credentials = new System.Net.NetworkCredential(username, password); 
     client.EnableSsl = true; 
     client.Send("[email protected]", "[email protected]", "This is a test subject.", "This is a test email message body."); 
    } 

的問題是,我得到以下異常:

SMTP服務器要求安全連接或客戶端未 認證。服務器響應是:需要身份驗證

是否有任何人有過相同或類似的問題?關於這個問題的任何建議?

+0

http://stackoverflow.com/questions/6477055/the-smtp-server-requires-a-secure-connection-or-the -client-was-not-authenticated \ [檢查此] – Usher

回答

1

這似乎是你使用的密鑰是錯誤的,請確認,否則創建一個新的。

確保發件人ID也被允許發送電子郵件,可以從Amazon ses控制面板完成相同的操作。

在你的代碼必須允許[email protected]發送電子郵件