Skip to content

C# Send Email over SSL on 465 port

Araz Farhang Da edited this page Apr 15, 2019 · 1 revision

How to send System.Net.Mail over SSL on 465 port

It is impossible for you to send email on 465 port using System.Net.mail and this is the mail goal that we have Aegis Implicit Mail (AIM)

Why do I have problem with port 465 while other ports are working?

Port 465 is a standard port that is used for Implicit Ssl SMTP communications. We have two types of SSL\TLS, implicit(SSL) and Explicit(TLS) As you might know, SMTP is in a way a normal socket communication which transfers specific packets. The difference between implicit and explicit ssl mail servers relays on handshaking. In implicit smtp communication the whole process in using SSL, including handshaking (usually port 465). If you secure a normal mail server with Ssl certificate, that will be come implicit, because you are having a security layer over all of transactions

How to Identify if my server is not an Explicit Mail Server?

The easiest way is using Aegis Implicit Mail library to [Detect Tls Support](How To Detect Tls Support).

Another easy way (but not reliable) is to look at port number. SMTP/SSL is often offered on port 465, but this is not registered, and is less common since support for explicit SSL is widely supported by SMTP agents. Some companies might use their own numbering.

There are IANA registered port numbers for secure mail, but some ISPs may use other ports. IMAP/SSL: 993 POP3/SSL: 995

The other way is to check if server has support for STARTTLS command. You can check this with telnet. When a client connects to an SMTP server, and issues the EHLO command, the server will list its capabilities, if you can find STARTTLS command it means that your server is supporting explicit connection.

Is there any alternative to send email to implicit ssl servers using .net?

Of Course but you may use the deprecated System.Web.Mail.MailMessage API (and set its "http://schemas.microsoft.com/cdo/configuration/smtpusessl" option, for explicit SSL/TLS):

System.Web.Mail.MailMessage mailMsg = new System.Web.Mail.MailMessage();
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl",true);

Another way is to establish a SSL/TLS tunnel to your server and send emails without usage of SSL. By using this way, you do the handshaking and transferring to SMTP server using ssl tunnel.

How to send Email over SSL on 465 port?

If you ask me, I would certainly advise you to use Aegis Implicit Mail (AIM). Just look at [Send Mime Mails to Implicit Ssl Smtp Mail Servers](Send Mime Mails to Implicit Ssl Smtp Mail Servers)

download_button

Why to use Aegis Implicit Mail?

  1. Firstly AIM (Aegis Implicit Mail) is free and open source library.
  2. It is easy to use
  3. Usage of AIM is exactly like System.Net.Mail, you can easily add implicit mail server support to your existing .net code.
  4. AIM also have extra features, like S\MIME support. You can use the same structure for signed and encrypted mails.
  5. Full support of PKI
  6. You can test connection and Auto detect Ssl Type using AIM