We have been using Aspose.Email succesfully for a long time connecting to several smtp services but now we are encountering very long connect times (over 15 seconds) with a specific server. After the first connect, emails are send quickly. Currently we are using Aspose.Email 21.4.0.0 with this code:
smtpClient = new SmtpClient(_mailConfiguration.SmtpServer, _mailConfiguration.SmtpPort, SecurityOptions.SSLExplicit);
smtpClient.HelloMessage = _mailConfiguration.SenderDomain;
smtpClient.AllowedAuthentication = Aspose.Email.Clients.Smtp.SmtpKnownAuthenticationType.Anonymous;
await smtpClient.SendAsync(mailMessage);
This is the log file of the smtp client:
-------------------------------------------------------------------------------
--- Aspose.Email for .NET [21.4.0.0] SMTP Client diagnostic log
---
--- Started: 01/12/2022 13:43:03
-------------------------------------------------------------------------------
Smtp client[1|01/12/2022 13:43:03]:
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Connect to: xxx.xxx.com:25 SecurityOptions.SSLExplicit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Environment version: 5.0.15 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OS version: Unix 4.15.0.188 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly title: Aspose.Email for .NET <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly version: 21.4.0.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]:
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp server[1|01/12/2022 13:43:03]: 220 xxx.xxx.com ESMTP Postfix
Smtp server[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: EHLO xxx.xxx.com
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp server[1|01/12/2022 13:43:03]: 250-xxx.xxx.com
Smtp server[1|01/12/2022 13:43:03]: 250-PIPELINING
Smtp server[1|01/12/2022 13:43:03]: 250-SIZE 10240000
Smtp server[1|01/12/2022 13:43:03]: 250-VRFY
Smtp server[1|01/12/2022 13:43:03]: 250-ETRN
Smtp server[1|01/12/2022 13:43:03]: 250-STARTTLS
Smtp server[1|01/12/2022 13:43:03]: 250-ENHANCEDSTATUSCODES
Smtp server[1|01/12/2022 13:43:03]: 250-8BITMIME
Smtp server[1|01/12/2022 13:43:03]: 250-DSN
Smtp server[1|01/12/2022 13:43:03]: 250 SMTPUTF8
Smtp server[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: STARTTLS
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp server[1|01/12/2022 13:43:03]: 220 2.0.0 Ready to start TLS
Smtp server[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp client[1|01/12/2022 13:43:03]: EHLO xxx.xxx.com
Smtp client[1|01/12/2022 13:43:03]:
01/12/2022 13:43:03
Smtp server[1|01/12/2022 13:43:19]: 250-xxx.xxx.com
Smtp server[1|01/12/2022 13:43:19]: 250-PIPELINING
Smtp server[1|01/12/2022 13:43:19]: 250-SIZE 10240000
Smtp server[1|01/12/2022 13:43:19]: 250-VRFY
Smtp server[1|01/12/2022 13:43:19]: 250-ETRN
Smtp server[1|01/12/2022 13:43:19]: 250-ENHANCEDSTATUSCODES
Smtp server[1|01/12/2022 13:43:19]: 250-8BITMIME
Smtp server[1|01/12/2022 13:43:19]: 250-DSN
Smtp server[1|01/12/2022 13:43:19]: 250 SMTPUTF8
Smtp server[1|01/12/2022 13:43:19]:
As you can see in the log, the response after the STARTTLS command is 16 seconds later. When I connect and send with openssl, the response is instant. Both in side the docker container, as on the docker host.
openssl s_client -connect xxx.xxx.com:25 -starttls smtp < testmail
We are using the ServicePointManager.ServerCertificateValidationCallback
to check the certificate of the smpt server, but during debug that code is not causing delays.
I hope anyone here has an idea how to improve this.
Kr,
Jeroen