System.net.Mail only supports explicit SSL

System. net. Mail sometimes fails to be sent under the ssl smtp server. After a while, it seems like this is the problem.

Sending mail using system. net. Mail with SSL will fail:

System. net.NetworkcredentialAcred =NewSystem. net.Networkcredential("Myacct","Mypassword");

SmtpclientSMTP =New Smtpclient("Smtp.mail.myserver.com", 465 );

SMTP. enablessl =True;

SMTP. usedefacrecredentials =False;

SMTP. Credentials = acred;

System. net. mail only supports "Explicit SSL ".

Explicit SSL

System. net. mail only supports "explicit SSL". Explicit SSL starts as unencrypted on port 25, then issues a startdls and switches to an encrypted connection. See RFC 2228.

Explicit sll wowould go something like:Connect on 25-> starttls (starts to encrypt)-> authenticate-> send data

If the SMTP server expects SSL/TLS connection right from the start then this will not work.

Implicit SSL

There is no way to use implicit SSL (smtps) with system. net. mail. implicit SSL wowould have the entire connection is wrapped in an SSL layer. A specific port wocould be used (Port 465 is common ). there is no formal RFC covering implicit SSL.

Implicit sll wowould go something like:Start SSL (start encryption)-> connect-> authenticate-> send data

This is not considered a bug, it's a feature request. There are two types of SSL authentication for SMTP, and we only support one (by design)-explicit SSL.

来源地址 https://topic.alibabacloud.com/a/zt-system-net-mail-with-ssl-to-authenticate-against-port-465_8_8_32240930.html

 
posted @ 2024-02-23 09:47  虹色流星雨  阅读(4)  评论(0编辑  收藏  举报