Reputation: 21
I have been sending Email by Google Apps Script successfully for sometimes. However, when I open a new Google Workspace account and use the same code to send the same things to the same receiver, the new account does not work. I get a message of "Message blocked" from [email protected]. It does not show any error description. When I send this message again in Gmail, the message can successfully reach the receiver. Any idea? Things are perfectly fine in my old Google accounts but not OK in any Google accounts I tried this month.
function myFunction() {
MailApp.sendEmail("[email protected]","From yyy","Hello!");
}
Upvotes: 2
Views: 1910
Reputation: 2861
Gmail thinks you are a spammer. Changing MailApp
for GmailApp
should work. In your case:
GmailApp.sendEmail("[email protected]","From yyy","Hello!");
The reason this is happening is because Gmail is flagging your email as a possible spam. This is likely because it is a new account, the contents of the message and configuration (like sending only plain text, no replyTo
or noReply
configuration, etc.). The Google algorithm is probably quite complex and there is no clear way of testing it. Here is an article talking about how to prevent being blocked.
Other people that had this problem seem to have success using GmailApp
instead of MailApp
(Stack Overflow question 1, Stack OVerflow question 2). The reason is probably how the services internally work.
Upvotes: 2