GuitarViking
GuitarViking

Reputation: 175

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.

Upvotes: 4

Views: 2182

Answers (2)

lamontfr
lamontfr

Reputation: 56

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

Upvotes: 3

GuitarViking
GuitarViking

Reputation: 175

I came up with a work around. I wish I didn't have to, but I was unable to get any help from Google or figure the problem out myself. Instead of having G Suite use Google Apps Script MailApp service to email my personal email address directly, I have G Suite Google Apps Script email itself (the email notification is sent to G Suite's own email address). I include a secret code in the message. Then I have a gmail filter in the G Suite account that forwards messages with the secret code to my personal email address automatically.

Upvotes: 1

Related Questions