Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It it possible to change the from address when using sendEmail?

I'm wondering if there are any options for changing the FROM address of an email sent using MailApp.sendEmail.

I've built a form that's published as a Web App. Students fill out and submit the form, and receive an email. I see how to change the email's reply-to address and sender name. I know that the email's using my address as the From address since I'm the script's owner and the app runs as me.

Is there any way to set the From address to belong to another person, in this case, the instructor? I'm assuming one way to accomplish this is to make him the script owner and walk him through re-publishing the app for us, but I'd rather not hand that over to him. (From what I've seen, only the script owner can publish the script.)

In other words, I want the From address to represent the client the script is being created for, not the programmer who's writing it.

I understand that it's not a desirable feature to allow a script to send email from anyone under the sun. I'm just wondering if anyone has a recommendation for how to solve my problem.

Thanks!

like image 988
Carrie Avatar asked Dec 14 '12 19:12

Carrie


People also ask

How do I change the from in Gmail?

1) Go to Accounts and Imports tab from Gmail settings page. 2) Click on 'Send mail from another address' button found user Send mail as section. 3) Follow the Gmail's instruction and you are done.

What is MailApp Sendemail?

MailApp. Sends email. This service allows users to send emails with complete control over the content of the email. Unlike GmailApp, MailApp's sole purpose is sending email.


1 Answers

If you use GMailApp.sendMail (instead of MailApp.sendEmail) you can specify a from as an optional additional parameter: https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

I believe you can only specify aliases that you have already configured your Gmail account with.

like image 131
chrisb Avatar answered Oct 02 '22 19:10

chrisb