邮件类库为 MailKit
端口采用 465
client.CheckCertificateRevocation = false;
client.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
client.Connect("smtpdm.aliyun.com", 465, SecureSocketOptions.SslOnConnect);
MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
This usually means that the SSL certificate presented by the server is not trusted by the system for one or more of
the following reasons:
1. The server is using a self-signed certificate which cannot be verified.
2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
3. A Certificate Authority CRL server for one or more of the certificates in the chain is temporarily unavailable.
4. The certificate presented by the server is expired or invalid.
5. The set of SSL/TLS protocols supported by the client and server do not match.
6. You are trying to connect to a port which does not support SSL/TLS.
See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#SslHandshakeException for possible solutions.
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
---> Interop+Crypto+OpenSslCryptographicException: error:14094410:SSL routines:ssl3_read_bytes:sslv3 <span><span>alert</span></span> handshake failure
--- End of inner exception stack trace ---
我解决了!
是openssl.cnf的配置问题。
根据以下网址解决:
【解决 .net 5 在ubuntu 18.x 20.x 下无法使用加密端口发送邮件】https://daqiao.info/archives/解决 net 5 正式版 在ubuntu 18x 20x 下无法使用加密端口发送邮件
可以点击问题下方的自己解决
结帖
建议改进一下排版,支持 markdown 语法
– dudu 3年前@dudu: 好的,已修改
– 懒瓜瓜 3年前@dudu: 已解决问题~
– 懒瓜瓜 3年前