Search code examples
google-apps-scriptgmailgoogle-workspace

G Suite Emails Sent with Google Apps Script Are Not Delivered "Message Blocked"


I have a few scripts that run in Google Apps Script. I was hitting the quota for time-based triggers on my free consumer account. So I signed up for G Suite to get larger quotas. The scripts are working, but the emails the scripts send (to my personal gmail account) are not delivered. They are returned with this message:

Message blocked Your message to *******@gmail.com has been blocked. See technical details below for more information.

The technical details link gives no useful information. Google support was not helpful either. They told me to search Stack Overflow.

I can send emails manually and receive emails manually. I have done so with the email address that the script is emailing to. But doing that did not change anything. Messages sent with any script are being blocked. I appreciate the help.

Here is the code that sends the email:

function testSendingEmail() { // This sends me an email
var emailAddress = "******@gmail.com"; var message = "This is a test message sent by G Suite."; var subject = "G Suite Test Message"; MailApp.sendEmail(emailAddress, subject, message); Logger.log(emailAddress, subject, message); }

I have tested this with two different gmail addresses. One gives the Message Blocked message immediately. The other email was not delivered, but I did not receive the Message Blocked message on that one.

(1) the desired behavior: I want the email to be delivered. It worked fine before I switched to G Suite. (2) a specific problem or error: The email messages sent from G Suite by a Google Apps Script are not being delivered. (3) the shortest code necessary to reproduce it in the question itself: I added the code.


Solution

  • I confirm that MailApp.sendEmail() was working in Gsuite in September 2018 but since sometime in October 2018 and until today, MailApp.sendEmail() only works from a Gmail account. However, GmailApp.sendEmail() works from either a Gmail or a Gsuite account. The solution was given in this thread : MailApp.sendEmail() in Google Apps Script not sending email