Error sending emails

Your software
My Mautic version is:4.4.2
My PHP version is:7.4.3
My Database type and version is: Maria DB 10.3.34

Your problem
My problem is: I’m sending about 180 emails in a batch, using SMTP to a google workspace account. After sending about 90 emails, the process ends with an error.

These errors are showing in the log:

[2022-09-23 19:13:26] mautic.ERROR: [MAIL ERROR] Expected response code 250 but got code "421", with message "421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp " Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  << 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp  !! Expected response code 250 but got code "421", with message "421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp " (code: 421) Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  << 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp  !! Expected response code 250 but got code "421", with message "421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp " (code: 421) !! Expected response code 250 but got code "421", with message "421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp " Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  << 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp  !! Expected response code 250 but got code "421", with message "421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp " (code: 421) (code: 421) (send); lviktorija165@gmail.com {"exception":"[object] (Swift_TransportException(code: 421): Expected response code 250 but got code \"421\", with message \"421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\"\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n<< 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\n!! Expected response code 250 but got code \"421\", with message \"421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\" (code: 421)\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n<< 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\n!! Expected response code 250 but got code \"421\", with message \"421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\" (code: 421)\n!! Expected response code 250 but got code \"421\", with message \"421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\"\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n<< 421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\n!! Expected response code 250 but got code \"421\", with message \"421 4.7.0 Try again later, closing connection. (MAIL) e24-20020ac84918000000b003445d06a622sm5640160qtq.86 - gsmtp\r\n\" (code: 421) (code: 421) at /var/www/html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124)"} {"hostname":"newmautic","pid":329606}
[2022-09-23 19:13:26] mautic.ERROR: [MAIL ERROR] Expected response code 354 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) !! Expected response code 354 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) (code: 0) (send); maalid@nevada.unr.edu {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 354 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0)\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0) (code: 0) at /var/www/html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124)"} {"hostname":"newmautic","pid":329606}
[2022-09-23 19:13:26] mautic.ERROR: [MAIL ERROR] Expected response code 250 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250 but got an empty response (code: 0) Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250 but got an empty response (code: 0) !! Expected response code 250 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250 but got an empty response (code: 0) (code: 0) (send); miaperkins2026@u.northwestern.edu {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250 but got an empty response (code: 0)\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250 but got an empty response (code: 0)\n!! Expected response code 250 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250 but got an empty response (code: 0) (code: 0) at /var/www/html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124)"} {"hostname":"newmautic","pid":329606}
[2022-09-23 19:13:26] mautic.ERROR: [MAIL ERROR] Expected response code 354 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) !! Expected response code 354 but got an empty response Log data: >> MAIL FROM:  >> RCPT TO:  >> DATA  !! Expected response code 250/251/252 but got an empty response (code: 0) !! Expected response code 354 but got an empty response (code: 0) (code: 0) (send); yasminmorales213@gmail.com {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 354 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0)\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response\nLog data:\n>> MAIL FROM:\r\n\n>> RCPT TO:\r\n\n>> DATA\r\n\n!! Expected response code 250/251/252 but got an empty response (code: 0)\n!! Expected response code 354 but got an empty response (code: 0) (code: 0) at /var/www/html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124)"} {"hostname":"newmautic","pid":329606}
[

Steps I have tried to fix the problem:
none.
Could this be due to the apparent throttling that Google imposes on outgoing GMAIL? Is something timing out? If so, how can this be fixed?

here a link to some information on troubleshooting Google code error. About SMTP error messages - Google Workspace Admin Help

More detail on the code 421

It looks like your ip address is temporarily blocked from using Google SMTP service. It’s possible the Google SMTP system thinks somehow your system was compromised and spamming so it’s blocking the ip from using it further.

Since the code page states it’s temporary, I would take this moment to check to see how many emails are you allow to send per seconds / minutes / hours and create a batch sending in cronjob to prevent triggering Google SMTP into a meltdown mode thinking you are a spammer.

It seems that the issue is due to number of emails I’m sending to Gmail, and the throttling they have in place. It appears that I’m allowed approximately 2 emails per second over time. When I try to send 100 emails or more, the delay waiting for the completion signal from the SMTP server is causing Mautic to think that something is amiss. If I send the same emails as two groups of 50, everything is fine. I need to figure out how to que the emails, and limit the number of items pulled form the queue at a time.

You would want to check out one of @joeyk video on this.