Search code examples
google-apps-script

Is 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!


Solution

  • Google is not flexible on this one - the only "from" address that you can see is the one belonging to the user whose authority is running the script.

    Instead of running as "the programmer", you can use a "robot" google account, something like [email protected]. You can develop your scripts as yourself, then republish them from the robot.

    Within a Google Apps Domain, your admin can create this psuedo-user and edit the settings to hide them from the Google Apps Directory, if that's desireable.

    The email that the students receive won't be from their instructor, but it won't be from you, either.