6

We've upgraded our application to Laravel 9 last week and noticed a large amount of failed jobs appearing as soon as we deployed the build in production.

Those errors were all email related with the following error message:

Expected response code "250" but got code "451", with message "451 4.4.2 Timeout waiting for data from client.".

We've reverted back to the previous build (which was using SwiftMailer) and the errors stopped. To clarify, we've been running the application for a few weeks and never had that error before.

On "Staging" we didn't have that issue. The only difference is we use SQS for queues in live and set :

APP_ENV=production
APP_DEBUG=false

that are the only differences.

mrakodol
  • 1,143
  • 3
  • 12
  • 41

1 Answers1

10

Could you try adding 'ping_threshold' => 10, to your smtp or ses configuration in config/mail.php

If you are using a queue worker/manager, remember to restart the process for the new configuration to come into effect.

This seems to have resolved the issue for me. Could be coincidental, but will report back if the issue returns.

MrCarrot
  • 2,546
  • 1
  • 23
  • 29
  • I found that this also fixed it for me - I set it to both ses and smtp in mailer array in mail.php. Strange... – Jonathan Bird Mar 24 '22 at 01:13
  • Scratch that... didn't fix my issue which started with the L9 upgrade from L8 – Jonathan Bird Mar 24 '22 at 01:24
  • That's a shame, it has fixed it for me (also L9 upgrade from L8) but we are using SES over SMTP and not SQS – MrCarrot Mar 24 '22 at 09:22
  • Seems that it fixed the problem. Was running jobs as a daemon. – Mantas D Mar 28 '22 at 12:09
  • 1
    Could you mark answer as correct, to help others – MrCarrot Mar 28 '22 at 19:03
  • Sorry, MrCarrot. I think that I do that. But looks like I forgot that. Sorry. – mrakodol May 18 '22 at 08:43
  • 1
    The SwiftMailer implementation [forced reconnections after each message](https://github.com/laravel/framework/pull/38481/files#diff-2310168aa86b70a22595ba784039cbdde829bd38245c9586eedd111dfd0f806dL523). To reproduce this exact behaviour, [you can specify `'restart_threshold' => 1,`](https://github.com/symfony/symfony/blob/96c2e10395d3e699c8a3cbced69bf77a0e55a7fc/src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php#L56) – AlbinoDrought Aug 08 '22 at 20:39
  • Where exactly do I add the `ping_threshold' => 10`? In `config/mail.php` I have this line `'driver' => env('MAIL_DRIVER', 'smtp'),`. In my app I do not have `ses` config file. – Guntar Aug 21 '23 at 03:27
  • When I'm sending the email it does get sent but I still get the the error `Expected response code "250" but got code "451", with message "451 4.4.2 Timeout waiting for data from client.".`. If I send multiple emails on the row (with few sec between), I noticed that the error gets town after second email. But both emails go get delivered. – Guntar Aug 21 '23 at 03:34