Reputation: 1
After someone (authorised and not myself) submits the Google form I created, which sends an email out to whoever they want, it shows that I (the Google form owner) sent it out myself. Is there a way to remove my email and show the email of the person who submitted the form?
This is the code in Apps Script
function onFormSubmit(e) {
let responses = e.namedValues;
MailApp.sendEmail({
to: responses['Email'],
subject: responses['Subject'],
htmlBody: responses['Message'],
});
}
I believe it might involve using Google Cloud Projects and an API, but I have little/no experience with those.
Upvotes: 0
Views: 567
Reputation: 38180
The problem occurs because your script is using an installable trigger and the Google Apps Script Mail service, as the script is ran using the credentials of the user who create the trigger, in this case you.
In order to send an email using the form submitter email address as sender, one option is to use
There might be other options to send the emails as the form submitter but all that have thinking about using Google Forms looks to be cumberstone.
A more simple option, still using Google Apps Script, is to create a web app and set it as run as the user accesing the web app.
The more simple solution to avoid showing your email address as the sender is to change the approach: use an alias with a generic name. To do this add an alias to your Gmail account, use GmailApp instead of MailApp and set the script to use the alias instead of your email address.
Upvotes: 1