I'm trying to send email via Amazon SES new SMTP service using .NET's built-in SmtpClient
Code:
var emailClient = new SmtpClient("email-smtp.us-east-1.amazonaws.com", 465);
emailClient.EnableSsl = true;
....
emailClient.Send(message);
I get an exception:
Unable to read data from the transport connection: net_io_connectionclosed
Google says this error means that I can't reach SMTP server. They require TLS which I beleive achieved by "EnableSsl" property.
Anybody know how I need to tweak my code to make it work?
EDIT:
I guess I will close this question. No, it's not possible to do what I want with SmtpClient
https://forums.aws.amazon.com/thread.jspa?messageID=302112񉰠
To send production email through Amazon SES, you can use the Simple Mail Transfer Protocol (SMTP) interface or the Amazon SES API.
With Amazon SES, you can send an email in three ways: using the console, using the Simple Mail Transfer Protocol (SMTP) interface, or using the API.
It is possible to do this by specifying port 587.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network enableSsl="true" port="587" host="email-smtp.us-east-1.amazonaws.com" password="[password]" userName="[username]"/>
</smtp>
</mailSettings>
</system.net>
With that as the configuration, you can use the SmtpClient as you normally would
var client = new SmtpClient();
var message = new MailMessage(fromemail, recipient, subject, body);
client.Send(message);
I can confirm that it works with STARTTLS and port 587.
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With