首页 新闻 会员 周边

.net5 项目部署到服务器后无法发送邮件

0
[已解决问题] 解决于 2021-01-29 15:02

邮件类库为 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 ---
小鹿呀的主页 小鹿呀 | 菜鸟二级 | 园豆:204
提问于:2021-01-29 11:32

建议改进一下排版,支持 markdown 语法

dudu 3年前

@dudu: 好的,已修改

懒瓜瓜 3年前

@dudu: 已解决问题~

懒瓜瓜 3年前
< >
分享
最佳答案
1

我解决了!
是openssl.cnf的配置问题。

根据以下网址解决:
【解决 .net 5 在ubuntu 18.x 20.x 下无法使用加密端口发送邮件】https://daqiao.info/archives/解决 net 5 正式版 在ubuntu 18x 20x 下无法使用加密端口发送邮件

小鹿呀 | 菜鸟二级 |园豆:204 | 2021-01-29 14:40

可以点击问题下方的自己解决结帖

dudu | 园豆:30994 (高人七级) | 2021-01-29 14:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册