Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has Google lowered the email limits for Google Apps Script?

Popular opinion seems to be that a Google Apps Script can send up to 500 e-mails per day. See, for example, What is the email limit on Google Apps Script?.

I checked the official quotas at script.google.com/dashboard and it says "Email Recipients: 100/day". Is that new, or am I looking at the wrong information?

A support article from November 2013 says "100/day" and an archived version says it was "500/day" in October 2013.

Every two or three weeks, we use a "mail merge" type of script to send personalized e-mail to 50-300 recipients. I'm quite sure we've sent to more than 100 in one day since November. Yesterday, we received a Service invoked too many times for one day: email error after 100 emails. So is this a recent change or is there another reason for the error?

like image 237
Dan Litwin Avatar asked Jan 29 '14 23:01

Dan Litwin


People also ask

Does Gmail allowing scripting?

The Advanced Gmail service allows you to use the Gmail API in Apps Script. Much like Apps Script's built-in Gmail service, this API allows scripts to find and modify threads, messages, and labels in a Gmail mailbox.

Can I send 100 emails at once in Gmail?

If you access Gmail via POP or IMAP clients, you can send an email to a maximum of 100 people at a time. This also includes emails sent through smtp-relay.gmail.com or smtp.gmail.com servers. If you surpass the limit, your account may be suspended for a day with the error – “550 5.4. 5 Daily sending quota exceeded.”

What is the max number of recipients for a Gmail email?

"You have reached a limit for sending mail" You may see this message if you send an email to a total of more than 500 recipients in a single email and or more than 500 emails sent in a day. When you get this error, you should be able to send emails again within 1 to 24 hours.


4 Answers

Eric Koleda of the Apps Script team announced this change on Jan 28, 2014.

We've just reduced the quota on the number of emails you can send per-day with Apps Script.

Consumer and non-paid Google Apps users are now limited to 100 email recipients per day, which is reflected on the Apps Script dashboard.

like image 125
Amit Agarwal Avatar answered Oct 20 '22 05:10

Amit Agarwal


Your question is already answered (yes, they lowered the limit), but I thought to offer up a a solution I just cobbled together to use a free MailGun account to overcome this limitation.

I'm probably doing lots of things wrong stylistically, but it's functional.

It just posts some variables to their HTTP API and hopefully throws an error if you get a bad result from them. Since my google apps script code is running on timed triggers, throwing these errors results in an email being sent to me.


function mailGun(payload)
{
  /*
   Edit the code:
    - to include a base64 encoded version of your api key
    - to include your domain in the mailgun URL

  Usage as below
  omit any parameters not needed
  other parameters are supported, see: http://documentation.mailgun.com/api-sending.html

   mailGun({
     from : "[email protected]",
     to : "[email protected],[email protected]",   //cc and bcc same format
     subject: "message subject",
     text: "plain text message"     //also able to do html - see api documentation
     });
   */



   // Because payload is a JavaScript object, it will be interpreted as
   // an HTML form. (We do not need to specify contentType; it will
   // automatically default to either 'application/x-www-form-urlencoded'
   // or 'multipart/form-data')
   var options =
   {
     "method" : "post",
     "headers" : {"Authorization" : "Basic <BASE64_ENCODED_VERSION_OF_MAILGUN_API_KEY>"}, //base64 of api:key-whatever
     "payload" : payload
   };

  var response = UrlFetchApp.fetch("https://api.mailgun.net/v2/<YOUR_DOMAIN_HERE>/messages",options);

  if(response.getResponseCode()!=200)
  {
    throw response.getResponseCode()+", "+response.getContentText()+", "+JSON.stringify(payload);;
    return 0; 
  }

  return 1;
}
like image 21
aberson Avatar answered Oct 20 '22 04:10

aberson


So is this a recent change or is there another reason for the error?

Per your archived link and the live quota page, this limit obviously changed between October and November of last year.

Both versions of the page also include the following statement:

All quotas are subject to elimination, reduction, or change at any time, without notice.

like image 2
admdrew Avatar answered Oct 20 '22 04:10

admdrew


I also see that the limit per message is 50 recipients, regardless of being a free account or a paid business account (as mine is). This I discovered because we have an app that needs to pull names from a spreadsheet and send a message those those users (these are users brought together only on the spreadsheet, and it can change, so a Google Group is not a good solution). With only 66 users (and it will likely never go above 100), I see no problem in making a throttling function that wraps around sendEmail() and sends to a portion of the users and sends the rest back into itself to continue processing until all have been sent the message. Here is my function (which does not account for CC or BCC, so keep that in mind if you plan to use it):

function email_throttle(recipients, subject, message, options) {
  // we are not parsing any passed options, so if you use CC or BCC, those people can receive multiple messages
  options = typeof options !== 'undefined' ? options : false; // options is optional

  // if recipients is a string, convert to array
  if (typeof recipients == 'string') {
    recipients= recipients.split(',');
  }
  var numRecipients = recipients.length;

  if (numRecipients > 40)  { // using 40 as a buffer, in case of CC and BCC in options

    // split out first group and send the email
    var theseRecipients = recipients.splice(0, 40);
    GmailApp.sendEmail(theseRecipients, subject, message, options);

    // send remaining recipients to email_throttle (recursive call to this function)
    email_throttle(recipients, subject, message, options);

  } else { // fewer than 40 recipients left

    if (numRecipients > 0) { // at least 1 recipient
      GmailApp.sendEmail(recipients, subject, message, options);
    }

  }
}
like image 1
Chris Avatar answered Oct 20 '22 05:10

Chris