我試圖使用亞馬遜的服務SES發送電子郵件:AWS SES郵件服務問題:端口?超時? STARTTLS?
String username = "&&&&&&"; // Replace with your SMTP username.
String password = "&&&&&&&"; // Replace with your SMTP password.
String host = "email-smtp.us-west-2.amazonaws.com";
int port = 25;
String senderAddress = "[email protected]";
String receiverAddress = inputEmail;
using (var client = new System.Net.Mail.SmtpClient(host, port))
{
client.Credentials = new System.Net.NetworkCredential(username, password);
client.EnableSsl = true;
String message = "Trucking On Demand received a request to reset the password for your account " + inputEmail + ".Your new password is: " + tempPassword;
client.Send
(
senderAddress, // Replace with the sender address.
inputEmail, // Replace with the recipient address.
message,
"This email was delivered through ****."
);
return Ok();
}
}
爲什麼我的請求超時?我試圖搜索互聯網,但除了要求我啓用TLS之外,aws並沒有明確的解決此問題的答案。我相信client.enablessl可以完成這項工作。我是否也需要處置我的客戶?即client.dispose();
你真的只是超時,或者你得到一個真正的錯誤?您在哪個地區配置了SES賬戶? orhtej2提供的鏈接就是一個很好的例子。我會從那開始,然後向後工作到您的代碼。注意:您必須使用端口587.端口25不受支持。 –