# Error sending emails

**URL:** <https://forum.mautic.org/t/error-sending-emails/25498>\
**Category:** Product Support\
**Created:** [September 23, 2022, 7:52pm UTC](https://forum.mautic.org/t/error-sending-emails/25498 "2022-09-23T19:52:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roblefko](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/roblefko/32/4958_2.png) [@roblefko](https://forum.mautic.org/u/roblefko)\
**Post date:** [September 23, 2022, 7:52pm UTC](https://forum.mautic.org/t/error-sending-emails/25498/1 "2022-09-23T19:52:45Z")

</div>

**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:

```auto
[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?

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [September 26, 2022, 2:27pm UTC](https://forum.mautic.org/t/error-sending-emails/25498/2 "2022-09-26T14:27:20Z")

</div>

here a link to some information on troubleshooting Google code error. [About SMTP error messages - Google Workspace Admin Help](https://support.google.com/a/answer/3221692)

More detail on the code 421

> **[Gmail SMTP errors and codes - Google Workspace Admin Help](https://support.google.com/a/answer/3726730?hl=en)**
>
> You may see the following error messages and codes when using Gmail with Google Workspace . The messages and codes are helpful tools for diagnosing and troubleshooting email problems.
> Gmail appe

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.

---

<div class="post-metadata">

**Author:** ![roblefko](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/roblefko/32/4958_2.png) [@roblefko](https://forum.mautic.org/u/roblefko)\
**Post date:** [September 26, 2022, 8:34pm UTC](https://forum.mautic.org/t/error-sending-emails/25498/3 "2022-09-26T20:34:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [September 27, 2022, 1:45pm UTC](https://forum.mautic.org/t/error-sending-emails/25498/4 "2022-09-27T13:45:17Z")

</div>

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

[![](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/44af713b74f2b3072d1812a03cfd5a2d33b32c8f.jpeg "This Is How Email Sending Works In Mautic") ](https://www.youtube.com/watch?v=fJcen6XDuEc)
