# MailKit在.NetCore5下发送邮件 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.
MailKit at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)

MailKit  版本 2.12.0  Linux Centos 7.9

 using (var client = new SmtpClient())
{
//  client.CheckCertificateRevocation = false;
//  client.ServerCertificateValidationCallback = (s, c, h, e) => true;
await client.ConnectAsync(_emailConfiguration.SmtpServer, _emailConfiguration.SmtpPort, SecureSocketOptions.Auto);
await client.SendAsync(mimeMessage);
await client.DisconnectAsync(true);
}

imap.exmail.qq.com(使用SSL，端口号993)

smtp.exmail.qq.com(使用SSL，端口号465)

openssl.cnf的配置问题

openssl_conf = openssl_init

[openssl_init]
ssl_conf = ssl_config

[ssl_config]
system_default = tls_defaults

[tls_defaults]
MinProtocol = TLSv1.2