jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.79k stars 360 forks source link

Error using smtprelay server.com Port 25. #1022

Closed s3YwCf2ZbfJG4SHAfjQMAjtsf closed 3 months ago

s3YwCf2ZbfJG4SHAfjQMAjtsf commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

Platform (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Configure an email server of smtprelay server.com Port 25.
  2. Attempt to send an email
  3. Get Error

Expected behavior System.Net.Mail will send the error but MailKit won't.

Error 2024-04-08 16:18:02,462 [.NET TP Worker] ERROR CI.MessagingLibrary.Services.MailKitService - Failed to send e-mail: MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.

When connecting to an SMTP service, port 25 is typically reserved for plain-text connections. If you intended to connect to SMTP on the SSL port, try connecting to port 465 instead. Otherwise, if you intended to use STARTTLS, make sure to use the following code:

client.Connect ("server.com", 25, SecureSocketOptions.StartTls);

---> System.Security.Authentication.AuthenticationException: Cannot determine the frame size or a corrupted frame was received. at System.Net.Security.SslStream.GetFrameSize(ReadOnlySpan1 buffer) at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](CancellationToken cancellationToken, Int32 estimatedSize) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Security.SslStream.ReceiveHandshakeFrameAsync[TIOAdapter](CancellationToken cancellationToken) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) at MailKit.Net.Smtp.SmtpClient.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken) --- End of inner exception stack trace --- at MailKit.Net.Smtp.SmtpClient.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken)

jstedfast commented 3 months ago

Did you read the error message? It tells you how to fix this.