I talked with google customer service the other day and they assured me that it’s possible for an account to send to up to 2000 emails per day. Today I tried to send a bulk email to about 1300 class participants. But it said it successfully sent to ~120 of them, before it errored out for the rest. The logs show an SMTP error 421 “try again later” (see below). I contacted google support and confirmed the sending account itself is not blocked for exceeding the daily limit, and they suggested it was probably sending too fast, and that you’re only allowed to connect once per second. They then showed me how to look up a log and it indeed seemed to be sending at a rate of about 2 per second.
So my question is: is there a way to slow down mail sending so that it doesn’t get blocked?
My secondary question is, when an email sending errors out like this, is there any way to pick it back up again, or do I just have to accept that ~120 people will get the same message again? (if I can find a way to resolve this issue.
[36;1mlms-worker_1 |[0m Traceback (most recent call last):
[36;1mlms-worker_1 |[0m File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
[36;1mlms-worker_1 |[0m R = retval = fun(*args, **kwargs)
[36;1mlms-worker_1 |[0m File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
[36;1mlms-worker_1 |[0m return self.run(*args, **kwargs)
[36;1mlms-worker_1 |[0m File "/openedx/venv/lib/python3.8/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 179, in new_function
[36;1mlms-worker_1 |[0m return wrapped_function(*args, **kwargs)
[36;1mlms-worker_1 |[0m File "/openedx/edx-platform/lms/djangoapps/bulk_email/tasks.py", line 334, in send_course_email
[36;1mlms-worker_1 |[0m raise send_exception # pylint: disable=raising-bad-type
[36;1mlms-worker_1 |[0m File "/openedx/edx-platform/lms/djangoapps/bulk_email/tasks.py", line 581, in _send_course_email
[36;1mlms-worker_1 |[0m connection.send_messages([email_msg])
[36;1mlms-worker_1 |[0m File "/openedx/venv/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 110, in send_messages
[36;1mlms-worker_1 |[0m sent = self._send(message)
[36;1mlms-worker_1 |[0m File "/openedx/venv/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 126, in _send
[36;1mlms-worker_1 |[0m self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
[36;1mlms-worker_1 |[0m File "/opt/pyenv/versions/3.8.6/lib/python3.8/smtplib.py", line 871, in sendmail
[36;1mlms-worker_1 |[0m raise SMTPSenderRefused(code, resp, from_addr)
[36;1mlms-worker_1 |[0m smtplib.SMTPSenderRefused: (421, b'4.7.0 Try again later, closing connection. (MAIL) r186sm3113766qkf.128 - gsmtp',