Email Task takes very long time

Hi Guys!
I’m in trouble with Email Task.
We’ve our smtp server w/out any ssl/tls configurations so we’ve set Octopus with the following data
SMTP Host: myrelay.mycompany.com
SMTP Port: 25
Timeout: 12 seconds (default)
Use SSL/TLS: No
From address: octopus@mycompany.com
Credentials: empty

The mail task often takes a long time, over 3 minutes!

Taking a look at Diagnostic area I’ve found the following warning

Connection attempt to SMTP host failed MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
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. The certificate presented by the server is expired or invalid.
    See MailKit/FAQ.md at master · jstedfast/MailKit · GitHub for possible solutions.

with the following stacktrace

—> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
— End of stack trace from previous location where exception was thrown —
at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.<>c.b__64_2(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)
— End of stack trace from previous location where exception was thrown —
at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
— End of inner exception stack trace —
at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
at Octopus.Core.Util.SmtpClient.SmtpClientWrapper.TryConnectToSmtpHost(SmtpConfiguration configuration, SmtpClient client, CancellationToken cancellationToken) in C:\BuildAgent\work\b5c671f6c6f2b660\source\Octopus.Core\Util\SmtpClient\SmtpClientWrapper.cs:line 127
Server certificate is not valid

Anyone can help me to figure out the problem?

Thank you!

Hi @fabrizio.mancin,

Thanks for getting in touch!

When configuring the SMTP settings within Octopus. Even if the Use SSL/TLS setting is unticked, if the SMTP server supports SSL/TLS this may still be used. It could be that this is the case and is causing the certificate error that you’re seeing.

Configuring the SSL trust on the Octopus server for the certificate on the SMTP server may resolve the issue.

You could also try testing with mailtrap to see if you encounter the same issue.

Regards,
Paul

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.