9

Using client.discovered_api('gmail', 'v1'), I'm sending an email using the gmail.users.messages.send function

It sends my messages fine, but when the quota of email is exceeded, there is no error.

I receive 200 OK and it all looks good.

"id": "15289b1d6b652c17", "threadId": "15289b1d6b652c17","labelIds": ["SENT"]

But for each message above the quota, I receive an email from Bounce (nobody@gmail.com) telling me:

You have reached a limit for sending mail.

This page says that I should receive 429 error code, but I don't.

Any idea what could go wrong? Or if there is a way to query the quota?

Edit: After investigations, even though email from nobody is received telling me quota is reached, the original email is sent anyway (meaning it's possible to go over the quota at the expense of receiving many nobody emails).

Edit2: I reported a problem on their API page, but still didn't hear anything from anyone. The lack of response is baffling.

Edit 3: Turns out their solution is just broken by design. There is a delay for updating the quota (can be more than 30 minutes... you can send a lot of emails in 30 min), so it lets you send and after tells your users that your message wasn't send after all (although it may have, given the tests I did). Totally unreliable. No information in the bounce to figure out what message was actually rejected. When you send 100 emails campaign on behalf of users, this is just not working.

5
  • Nice find :) Sounds like a bug, or at least an error in the documentation. Maybe file an issue for it?
    – Tholle
    Jan 29, 2016 at 1:12
  • 1
    Thanks, I did: code.google.com/a/google.com/p/apps-api-issues/issues/… . No Reply so far. I have 600 users migrated over the gmail api so it's not fun, it's hard to believe I'm the only to bump into this :/
    – Jeremy
    Jan 29, 2016 at 12:29
  • Bummer :( Migrating as in inserting all old messages of your users into gmail? Have you tried inserting? It does not count towards the sent message quota.
    – Tholle
    Jan 29, 2016 at 12:43
  • 2
    No, I have a software that automates sending emails, and I switched recently from SMPT (working fine when going over quota, you receive an error as expected) to using the gmail api (and found this problem as I answer support questions)
    – Jeremy
    Jan 29, 2016 at 14:02
  • 1
    Ah, I see. I hope a Google pro sees your issue soon!
    – Tholle
    Jan 29, 2016 at 14:12

2 Answers 2

4

Here is the answer after more than 1 month waiting.

"I spoke with the Gmail API engineering team, and unfortunately this is working as intended. Gmail quotas aren't computed within the span of the Messages.send() request, but rather asynchronously as the email enters our sending pipeline. The quota state of the user will be synchronized across the system, and you'll get 429 errors, but there is a small time between when the quota has run out and the API has realized it. You could scan the inbox for bounce messages, but that's not a great workaround. In general I think you should assume that sending email is best effort and that your application can't assume that a 200 response means the message was sent successfully. We'll update the documentation to make this clear."

How stupid is that? I'm back to sending via SMTP, at least you get the reply immediately and user don't receive cryptic quota messages in their inbox.

EDIT: This has been updated to "won't fix", they only updated the documentation. Totally retarded.

"The mail sending pipeline is complex: once the the user exceeds their quota, there can be a delay of several minutes before the API begins to return 429 error responses. So you cannot assume that a 200 response means the email was successfully sent."

0

According to Google email sending limits, the Gmail API enforces the standard daily mail sending limits (these limits differ for paying Google Apps users vs free gmail.com users).

If you exceed the Google Apps email limits, you may see an error messages as such:

  • You have reached a limit for sending email
  • You reached a Gmail sending limit
  • You exceeded the maximum recipients

To verify your quota usage, the easiest way to check if you have exceeded your quota limit or request more quota is via Developer Console.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.