0

first, i've discovered through trial and error that c# 4/.NET 4 has some serious limitations which are to me unexplainable.

Microsoft is not supporting SSL over port 465 in c# 4/.NET 4.

Microsoft only supports SSL on 587 through "STARTTLS".

i need to use 465/SSL because my mail server hMailServer does not support "STARTTLS".

i had hoped to use c# 4/.NET 4 out of the box ... i do not want to purchase any third party solutions.

what i would like to do is to craft my own solution for SMTP using SSL on port 465.

i'm guessing that i may have to use c# unmanaged code to make this happen.

any ideas?, please & thank you. rgds/gerry

References:

"configuring SSL confusion...", hMailServer forum thread.

MSDN: "SmtpClient.EnableSsl Property":
"An alternate connection method is where an SSL session is established up front before any protocol commands are sent. This connection method is sometimes called SMTP/SSL, SMTP over SSL, or SMTPS and by default uses port 465. This alternate connection method using SSL is not currently supported."

P.S.: i searched SO and Google and can find nothing directly relevant.

Bruno
  • 119,590
  • 31
  • 270
  • 376
gerryLowry
  • 2,626
  • 5
  • 35
  • 44
  • 1
    STARTTLS > SMTP over SSL – Joel Coehoorn Dec 04 '11 at 20:46
  • 1
    @Joel, STARTTLS is for SMTP over SSL/TLS, after upgrade from plain SMTP, as opposed to SMTPS (which can also be called SMTP over SSL) where the TLS connection is established from the start: http://stackoverflow.com/questions/3660798/what-happens-on-the-wire-when-a-tls-ldap-or-tls-http-connection-is-set-up/3661416#3661416 – Bruno Dec 04 '11 at 21:15

3 Answers3

0

You can establish a ssl TCP/IP connection to your smtp server, generate proper commands and headers and send them throw it. However, this would be too confusing. I have done it already in [Aegis Implicit Mail (AIM)] (https://sourceforge.net/projects/netimplicitssl/) project. Try to download it's source code and have a look.

You can find out the answer of all your problems here

Nil Null
  • 414
  • 5
  • 14
0

As you already discovered MS says clearly that what you want is NOT supported "out-of-the-box".
AND you don't want to use any 3rd-party library.

Possibilities to accomodate both:

  • you could implement the needed protocol (SMTPS) yourself (not recommended!) OR
  • use some TCP tunneling mechanism/proxy (which in turn means again a 3rd-party library) OR
  • you could switch from your current SMTP server (hMailServer) to one that supports STARTTLS

EDIT - as per comments some libraries supporting "SMTP with implicitc SSL":

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • although, preferably, i do not want to purchase any third party solutions, i'm willing to check them out and to also look into open source, so, yes, please do provide some links. thnx. – gerryLowry Dec 04 '11 at 22:24
0

If you can, and if it still works ("This API is now obsolete"), you should be able to use SMTPS (SMTP with up-front SSL/TLS) using System.Web.Mail.MailMessage:

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

Of course, the fact that this API is now obsolete in .Net 4 is not ideal. It probably still works in practice.

Failing that, you may have to rely on 3rd-part libraries or something like stunnel.

Bruno
  • 119,590
  • 31
  • 270
  • 376
  • thank you ... i'm aware of the deprecated System.Web.Mail API; i'm uncomfortable at using anything where Microsoft could "pull the plug" at any time. – gerryLowry Dec 04 '11 at 22:26
  • @gerryLowry, depending on how this needs to integrate with the rest of the system (in particular regarding licensing), running stunnel alongside your application should help. – Bruno Dec 05 '11 at 14:37