GmailApp.sendEmail 'from' option not working

486 views
Skip to first unread message

Peter Berkhout

unread,
Jul 16, 2023, 2:29:32 PM7/16/23
to Google Apps Script Community
I can't get the following code:

GMailApp.sendEmail('m...@mydomain.nl','Subject of this email',Logger.getLog(), {name:'Save attachments from triggered attachment script',from:'log...@mydomain.nl'}

to actually put the from email address in send emails from my Google Workspace account. All emails from the script have m...@mydomain.nl (which is the default address for my domain) as the from email address.

I can send with the log...@mydomain.nl from the Gmailapp without a problem. It is just that within GAS it doesn't work. I also tried different aliases. Same results.

log...@mydomain.nl is is one of my aliases and it is in the returned list of GmailApp.getAliases(). I tried with both 'treat as an alias' checked and unchecked.

Do you have an idea as to what the problem might be? Thanks in advance.

Regards,

Peter Berkhout

Damir Makhmudov

unread,
Jul 16, 2023, 2:47:26 PM7/16/23
to google-apps-sc...@googlegroups.com
What the problem do u face with?
Share output of script. And explain it more detail pls

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/79529c99-de11-4a36-847b-7d052ec9baf5n%40googlegroups.com.
--

Damir Makhmudov

CBMServices Web

unread,
Jul 16, 2023, 10:43:46 PM7/16/23
to google-apps-sc...@googlegroups.com
Hi Peter,

I don't believe you can change the from email address. You can change the name and the reply to email address but not the from emailaddress. Otherwise this would be a great way for people to send phishing emails and fooling the recipients.


--

Peter Berkhout

unread,
Jul 17, 2023, 8:18:09 AM7/17/23
to Google Apps Script Community
Thank you for your answer but According to Google's documentation you can, but only if it is one of your registered aliases. 
See: https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)
It is one of my aliases but it just doesn't work. I think I have to report as a bug and see what Google's answer is.



Op maandag 17 juli 2023 om 04:43:46 UTC+2 schreef George:

Peter Berkhout

unread,
Jul 17, 2023, 8:43:47 AM7/17/23
to Google Apps Script Community
I resolved the mystery:
https://stackoverflow.com/questions/76697770/gmailapp-sendemail-from-option-not-working


Op maandag 17 juli 2023 om 14:18:09 UTC+2 schreef Peter Berkhout:
Reply all
Reply to author
Forward
0 new messages