Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email via Amazon SES SMTP error

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&#302112

like image 985
katit Avatar asked Dec 28 '11 20:12

katit


People also ask

Does SES use SMTP?

To send production email through Amazon SES, you can use the Simple Mail Transfer Protocol (SMTP) interface or the Amazon SES API.

Can I use AWS SES to send email?

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.


2 Answers

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);
like image 106
cbeckner Avatar answered Sep 20 '22 01:09

cbeckner


I can confirm that it works with STARTTLS and port 587.

Hope that helps

like image 28
Masterfu Avatar answered Sep 21 '22 01:09

Masterfu