Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# send email using implicit ssl

Tags:

c#

.net

email

ssl

Is there any library preferable free that can be used in order to sens email using implicit ssl protocol. My hosting provider support ssl emails ... but standard .net email client cannot handle that.

like image 842
Radu D Avatar asked Feb 22 '23 19:02

Radu D


2 Answers

Use the TLS port (ie 587) rather than the SSL port. I had the same issue for months until I found this solution.

Sending email in .NET through Gmail

like image 109
durbo Avatar answered Mar 06 '23 09:03

durbo


System.Net.Mail does support "explicit SSL" (also known as "StartTLS" - usually on port 25 or 587), but not "implicit SSL" (aka "SMTPS" - usually on port 465).

As far as I know, explicit SSL starts from an unsecured connection, then the STARTTLS command is given and finally a SSL secured connection is made. Implicit SSL, on the other side, requires that the SSL connection is set up before the two parties start talking.

Some servers (like gmail) accept both, so you simply need to set EnableSsl to true and send to the right port. If your server does not support explict SSL, though, this "simple way" is not an option.

I'm also still looking around for a general solution for using System.Net.Mail with implicit SSL, with no luck so far.

Anyway take a look at this article, it may give you some insight.

[edit: @Nikita is right, fixed port numbers to avoid confusion]

like image 21
Luke Avatar answered Mar 06 '23 10:03

Luke