Mails not sending

Your software
My Mautic version is: 3.3.3
My PHP version is: 7.4.18
My Database type and version is: MySQL 8.0.25-0ubuntu0.20.04.1

Your problem
My problem is:
We have a Mautic instance running with Mailjet as mail provider, which has always served us nicely, but about 2-3 weeks ago, we started getting problems.

Some mails that are send by a campaign in Mautic don’t get send for a while. Even when they retry they sometimes fail for the same reason.

The weird thing is that sending test mails to myself and even from when I join the campaign myself I receive the emails. This goes for sending test mails from the mail setting menu, as well as the mail sent by the campaigns which give those errors

We have the retry campaign event set up for 30 minutes and sometimes after 30mins it does get sent, but other times it doesn’t. This is all happening without any consistency.

These errors are showing in the log:

[2021-06-22 11:40:31] mautic.ERROR: [MAIL ERROR] Expected response code 250 but got an empty response (send); somemail@mail.com {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /var/www/vhosts/domain.com/htdocs/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:445)"} []
[2021-06-22 11:40:31] mautic.ERROR: [MAIL ERROR] Expected response code 354 but got an empty response (send); othermail@mail.com {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 354 but got an empty response at /var/www/vhosts/domain.com/htdocs/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:445)"} []

These errors are not showing in the log, but sometimes when I run the job myself rather than running it by cron:

PHP Warning:  fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409E10F:SSL routines:ssl3_write_bytes:bad length in /var/www/vhosts/domain.com/htdocs/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 231

Unfortunately I cannot see why this is happening and more importantly why this only happens sometimes.

Steps I have tried to fix the problem:
Reset the mail config and used another Mailjet account.

Another thing I found
Since the campaign event has errored, you would expect the next events to not execute until this one is executed successfully. The last action in some of these campaign is removing the contact from the campaign after 1 hour, but sometimes this happens before the mail can be send. In this case the contact is removed from the campaign before the mail is sent, so the mail will never try to get sent again.

I am following similar issue and I have detailed about it in this post:
https://forum.mautic.org/t/command-swiftmailersend-exited-with-status-code-1/21905/3