Google marks emails sent from spreadsheet with MailApp.sendEmail as phishing scam - google-apps-script

I am using a variation of Google's MailApp.sendEmail() script ( https://developers.google.com/apps-script/articles/sending_emails) to send emails to addresses in a spreadsheet. To test the script I am sending them to another gmail account. However, the emails are being marked with the message: This message may not have been sent by: foo#gmail.com. Is there any way to avoid this? Thanks!

This warning isn't caused by the MailApp.sendMail() script. The phishing warning only shows up when I send email between two gmail accounts (both of which belong to me). It doesn't show up when I send email to other accounts using the MailApp.sendMail() script. The warning also appears when I send a standard gmail message from one account to the other, when the sending account is a consumer account, and the receiving account is a university account. The message does not appear on emails from other people's gmail addresses and does not appear on messages sent from my university account to my consumer account.

Related

MailApp.sendEmail() not sending from current user

I have an onEdit triggered appscript that grabs data from a spreadsheet, formats it and then sends it to an email address. Typically these messages would be sent 'from' the user that is triggering the script to run. However, I am experiencing strange behavior where the current user is not used to send the message - or used inconsistently.
A couple of notes:
Occasionally the message is sent by the current user, other times it is not (in those cases it comes from my account, which created the script)
Script trigger is an 'onEdit' script which monitors the sheet for a checkbox status change
Spreadsheet is in a Shared Drive
We are using Google apps for education
The recipient address is a mailing list tool. When I list a different email address as the recipient (internal, external, other) the message consistently comes from the current user as expected. I've no idea why the recipient would affect how Google sends the message.
I realize i could use the GmailApp library to send instead, but want to avoid the re-authorizations that are mentioned.

Trying to setup a google service account. Email generated doesn't work

I am trying to setup a google service account so I can access a google sheet from python. I generated a .json file with a client email. However when I share this email in my sheet I get a Delivery Status Notification (Failure):
"Your message wasn't delivered to scantling-io#dnv-strucuture-calc.iam.gserviceaccount.com because the domain dnv-strucuture-calc.iam.gserviceaccount.com couldn't be found. Check for typos or unnecessary spaces and try again."
The email is exactly the one that came in the json file. Any ideas why it isn't working?
You should uncheck the "notify people" option when sharing the Spreadsheet with the service account, this is because service accounts don't have an inbox or Gmail account associated.
You could only access to another user's Gmail data by impersonating the user with a service account with domain-wide delegation.

Google script to forward email to recipient

While creating a rule in google admin I accidentally made a mistake and all the emails in my enterprise where sent to a specific email account. The emails skipped the inbox of the actual recipient and were sent to a global inbox.
Is there a script I can write to undo this meaning forwarding the email to the user who were suppose to receive this.

MailApp returns a delivery failure with Gsuite account, but not with Gmail

I have tested a Google Apps script to send a google doc converted to PDF by mail automatically. The email is sent to one email address at a time.
I tested this with my normal Gmail account and it worked fine.
But when I try to use it on my Gsuite account (professional mail), I get a "delivery failure" mail with this error inside it :
Message blocked
Message rejected. See https://support.google.com/mail/answer/69585 for more information.
After calling the google assistance, I activated the "allow unsafe application access". It's been 4 hours now since I've activated this option (the option says that it might take some time to get into effect), but the error is still there.
Do you know why such an error may be generated ?
The link provided in the delivery failure mail does not provide precise information about this mail, apart from general indications like maybe it's "spam", "the recipient does not exist", etc...
Such indications does not qualify with this mail because the fact is that I know it's usually working on my Gmail account. I don't know why it's blocked with the Gsuite account.
EDIT : When I send the same mail manually with the Gsuite account, with the same title, body and attachment, the mail goes through without any issue.
I have to point that I did not shared documents/sheets or the script between the two accounts (because it has generated weird script behavior in the past). I copy-pasted the documents and the scripts in my new Gsuite account. My Gsuite account is the only owner and has the only access to the documents and the script, without any sharing.
Here is the portion of the script used to send the automated email :
//recipientmail is defined elsewhere
//newPDFReportId is defined elsewhere
if (recipientmail !== null) {
MailApp.sendEmail(
recipientmail,
"EMAIL OBJECT",
"Hi !\r\rThis is an example of an automated mail.\r\r\rDon't hesitate to get in touch.\rThis is the alpha version of the email sender.",
{attachments: DriveApp.getFileById(newPDFReportId)})
}
I solved the delivery failure of the automated mail by using GmailApp instead of MailApp in my script.

GAS MailApp allways sends a copy of email to script owner's email too

I just wanted to know if this behaviour is normal. Is it suppose to send a copy of the mail to me as the script owner, as well as the intended recipient? For example this code:
function emailTest(){
MailApp.sendEmail("someemail#gmail.com","test subject","test body");
}
Will send out an email to someemail#gmail.com. I will also get a copy in my inbox as the script owner. Can I shut this off somehow?
Regards,
Shumway
Because you're sending the mail from your account, you'll see the message in your 'Sent' box. If you're seeing it in your Inbox, it's not related to the script itself, as this is only sending to "someemail#gmail.com".
Things to check:
You don't have a forwarding rule from "someemail#gmail.com" to your account.
You don't have a filter/mail client/ other service accessing your inbox and placing your sent mail in the inbox.
You're not looking at 'All Mail'. Etc, etc.
You can probably get help for this at: https://productforums.google.com/forum/#!categories/apps/mail-settings.