-
Notifications
You must be signed in to change notification settings - Fork 17
C# Send Email 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)
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
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.
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.
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)
- Firstly AIM (Aegis Implicit Mail) is free and open source library.
- It is easy to use
- Usage of AIM is exactly like System.Net.Mail, you can easily add implicit mail server support to your existing .net code.
- AIM also have extra features, like S\MIME support. You can use the same structure for signed and encrypted mails.
- Full support of PKI
- You can test connection and Auto detect Ssl Type using AIM