1

I have some a script with trigger set up to send emails daily with GSuite account (about 10 triggers to send about 15 email in total per day, average 6 recipients/email.

However, last few days, I got the alert:

Exception: Service invoked too many times for one day: email

when running the script by trigger or by manually.
I do not think I hit the quota of sending email daily of Google. This morning, when I check the quota remaining by function MailApp.getRemainingDailyQuota(), I only get 4 email remaining. I do not know what happened.

Is there anyone could please help me to solve this problem?

This is the alert I receive:

Your script, AutomaticSendingEmail, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.

Start             Function                    Error Message                                                                   Trigger End
6/13/20 3:59 PM   send_overtimerequest_email  Exception: Service invoked too many times for one day: email.   time-based  6/13/20 3:59 PM

Sincerely,

  • Try using GmailApp instead of MailApp – Cooper Jun 16 '20 at 03:12
  • 1
    Welcome to [so]. The question doesn't include enough details. Please add more details like a [mcve] and how may emails were sent in the 24 hours before reciving the warning (you could check your Sent view in Gmail) and how many times the email function was executed. – Rubén Jun 16 '20 at 03:27
  • Does this answer your question? [Service invoked too many times for one day: email](https://stackoverflow.com/questions/58654663/service-invoked-too-many-times-for-one-day-email) This is the only question I found so far that has an answer getting in detail regarding the email service quota. Ofc, we can use other services as targets, as the message has the same root causes... – Oleg Valter is with Ukraine Jun 16 '20 at 03:33
  • [This one](https://stackoverflow.com/questions/2744520/what-is-the-email-limit-on-google-apps-script) might be a better, though (btw, Cooper, with your answer). That said, it might be linked to how many times triggers fire - sometimes they fire more than once (also, 10 triggers for 15 emails seems like quite an overkill - why don't you use a batch send, is there a specific reason to setup that many?) – Oleg Valter is with Ukraine Jun 16 '20 at 03:56
  • 1
    Dear Oleg Valter, I have many file google sheets data and need to send to different departments for 2 times/day. I do not know how to use batch send, could it help to solve ? Thanks. – Linh Nguyen Jun 16 '20 at 06:26
  • Dear Rubén, I have checked the sent email box and found out that it sent 20 emails yesterday before getting the alert. Thanks for your support. – Linh Nguyen Jun 16 '20 at 06:29
  • `15 email in total per day, average 6 recipients/email.` When you say 6 recipients, are you sending one mail for every recipient or one mail including every recipient. If you are doing the first take into account that you are speeding by 6 your quota consumption. – Raserhin Jun 16 '20 at 15:55
  • 1
    Dear Raserhin, I configured to send each email have 06 recipients. And I found that Google will count the quota based on the recipients in total not on the number emails. – Linh Nguyen Jun 17 '20 at 04:44
  • @LinhNguyen - what I meant is to use a single *trigger* for all departments (maybe create a [standalone](https://developers.google.com/apps-script/guides/standalone) Web App to deal with this (in depth help with that is out of scope of SO, I am afraid) - you don't send them emails at 10 different *times*, do you? – Oleg Valter is with Ukraine Jun 17 '20 at 04:56
  • 1
    Dear Oleg, Yes, let me try this way. Thank you for your help. – Linh Nguyen Jun 18 '20 at 04:36

1 Answers1

1

Looking at the page for Apps Script quotas it does specify that the limitations per day is counting recipient (100 recipient/day), so in this case you have no much option. Make sure that you are using the correct account because the limitation for G Suite accounts are 1500 recipient/day. Also check out if this may be applying to you right now:

Note: Newly created G Suite domains are subject to the consumer limit for the first billing cycle if they have six or more users, or several billing cycles if they have fewer users. For more information, see the Help Center page on sending limits.

A workaround that I would suggest is to have a service account and use Domain Wide Delegation to impersonate and user then make use of the Gmal API

Raserhin
  • 2,516
  • 1
  • 10
  • 14