Learn-to-send-email-via-google-script-html-no-server: email limits causing script to silently fail

Created on 14 Sep 2016  路  8Comments  路  Source: dwyl/learn-to-send-email-via-google-script-html-no-server

Sort of a multiple bug here but all related. If you send over the account quota of emails per day, then the script will silently fail all POST requests. This means that not only is your form data NOT sent to your email, but it also does not make it into the form. Double bummer! For a personal account, this only supports 100 emails per day. This should also be mentioned in the tutorial, as there are this and a few other limitations to the entire script.

https://developers.google.com/apps-script/guides/services/quotas

Disabling the email submission or putting it after the form data is ideal. There is a separate issue of the error messages not propagating to the user (and they should), which someone brought up in another issue. The error displays in the console, but users won't know that. Major bugs here.

Priority-1 help wanted wontfix

All 8 comments

Lame. getting punished for _success_... :-(

Well, in this case, an error is what occurs (and shows in the user's console too), hence the silent fail right now. We need better error-checking here so that the user knows their data isn't sent, first of all.

Second, we want to improve the script to do separate try/catch blocks for the spreadsheet, and THEN the email. I am still a little curious if the limit -IS- what I hit for sure, as I would have to submit 101x to check this (kind of a pain by hand). Might be worth spinning up some Node.js to test this. Then these could be used as tests for the repository!

Lastly, how important is the email and then the storing in a spreadsheet? Currently, some can do either, or both. If one fails, it might not matter for some use-cases, similarly for the other. Or both might matter. I use both as a redundancy measure. I have used it for 150+ sensitive data submissions across browsers and only had 3 errors so far, aside from the API limit or whatever I hit. I just wonder which is a priority to catching/testing errors and to pitch more in the tutorial, if that makes sense...

Not sure. I am not 100% that the email quota is the issue. I would need to recreate the situation and print out the error to find out for sure.

Google Apps for Work/Edu/Gov supports up to 1500 per day, rather than the personal google account limit of 100. However, it states in the quotas that this is _recipients_ per day... I was always sending that email to myself, one email, so not sure what else could have broken. There are many, many other quotas, from time taken for a single script, time for all scripts in a day, too many simultaneous scripts, etc. etc. There are a lot of various quotas, and it really would be best to create an artificial test using a server to find the issue (and handle the failures gracefully). I think it can still store the data in the spreadsheet but maybe just fail to send an email, but I am not 100% sure. After disabling email sending, I had no other issues receiving many responses in a day (as far as I know).

Encountered this problem today while trying out another script to send emails from google sheets. After running the script with a line error I sent myself 86 emails containing empty lines.

I have been testing your script on several forms at once and all scripts authorized by my google account stopped working. Did not debug the problem any further, just copied the script into new projects created on a separate google account and then injected the new action script url into my existing HTML.

Not offering any kind of solution just confirming the bug, and maybe an idea on how to exceed the quotas in another manner then filling out a form by hand a 100 times.

I believe this is the script I used. I abandoned the idea since the forms are more important to me :
function CustomEmail() { var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange("A1:G"); var UserData = range.getValues(); for (i in UserData) { var row = UserData[i]; var val1 = row[0]; var val2 = row[1]; var val3 = row[2]; var val4 = row[3]; var val5 = row[4]; var val6 = row[5]; MailApp.sendEmail("[email protected]", "Email subject", "Message" + val1 + ", " + val2 + " containing " + val3 + "the " + val4 + " total " + val5 + " values" + val6); } }

Thanks @Dra7 ! That is one way to test it for sure. Thanks for the share!

It is nice (though unfortunate) that this is confirmed. Even worse so that it stops any scripts from your account - yikes!

We could have a fall-back, so that emails may fail, but storage in a spreadsheet continues. This would ideally notify the script maintainer in some way. Perhaps we could catch the error in Google Scripts for this. However, it calls into question the purpose of the repo. The initial name is about sending an email (not storing in a Google Spreadsheet). I have used this repo more for storing data in a spreadsheet (with email as a data backup). What is the main use-case for this repo? As that would determine the best next steps.

FYI, the script will currently try to store data in a spreadsheet FIRST, so in case the email API limit is reached, you will not lose data in the spreadsheet, at least (but no email will get sent).

Since this is a limitation of the Google API, I don't think we can fix this beyond this. But, we should probably put a note or two in the tutorial for others to be aware of.

@mckennapsean good point. we should inform people that there are (_email_) limits and storing in the spreadsheet first is a good safeguard when reaching them. 馃憤

Notes were added to the tutorial, so this should be addressed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shaily99 picture shaily99  路  4Comments

JintaYadomi picture JintaYadomi  路  3Comments

joshiadvait8 picture joshiadvait8  路  3Comments

EugeneFitzher picture EugeneFitzher  路  4Comments

joseroma picture joseroma  路  3Comments