c# 4.0 - how to i SMTP with c# 4/.NET 4 to port 465/SSL (...

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.

 

 

 

f 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.

posted on   大西瓜3721  阅读(367)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)

导航

点击右上角即可分享
微信分享提示