11

I'm familiar with how to send emails via Google Apps Script (http://code.google.com/googleapps/appsscript/articles/sending_emails.html). It's super cool. But is there a way I can email from Apps Script from another email address that I have access to? It seems like I can specify a reply to address, but the user still sees the email as from my primary user account, I believe.

Example: My email is user@domain.com, but I'd like to send the email from event@domain.com from the Apps Script Javascript.

Thanks for any advice.

Garen Checkley
  • 5,512
  • 6
  • 22
  • 24

3 Answers3

13

The only way to achieve that is by logging with the account of desired email, in your case "event@domain.com" and run the script with it. If you're running the script automatically via a trigger, just set the trigger with this account. If you do not have an account for it, you'd have to create one.

Adjusting the from field is not possible. There's an open issue about this on Apps Script tracker: Issue 172: Ability to send email from users different accounts ("from:" field in gmail)

--update: as one can see by following the link above, this is now possible if the desired address is an alias in your gmail.

Henrique G. Abreu
  • 17,406
  • 3
  • 56
  • 65
  • Note that even with the update, your primary Gmail account's email address _is revealed_ if you show the original message with full email headers, even when sending from an alias. – nhinkle Sep 11 '15 at 07:34
9

Try this

var alias=GmailApp.getAliases();//This gets array of Aliases set up in gmail.
GmailApp.sendEmail(email , "Subj.. ", "body....", {from: alias[0]}); //Uses first alias
Nunser
  • 4,512
  • 8
  • 25
  • 37
  • 1
    This is now the way to do it, still need authorization but it works. You can also get away with `GmailApp.sendEmail(email , "Subj.. ", "body....", {from: "name@domain.com"});` – Patrick Zawadzki Oct 28 '15 at 01:14
1

My gadget/script [1] does precisely that, you can reply to many emails at once from within your GMail account.

Basically I just used the Publish / Deploy as web app command (from the script editor) and in there set the options

Execute the app as: User accessing the web app

Who has access to the app: Anyone

Users then will be asked to authorise the script the first time they access it and they will run it from their own Google account, accessing their own Gmail.

[1] https://sites.google.com/site/replytomany/

amsmota
  • 171
  • 2
  • 11