Skip to content
// Forms · Gmail · Apps Script

Email the respondent after form submission in Google Forms.

Send a confirmation email to the person who filled out your Google Form automatically, using Apps Script with an installable on-submit trigger and e.response.getRespondentEmail().

I want Google Forms to automatically send a confirmation email to whoever just submitted my form, without me doing anything manually.

The script

copy · paste · trigger
confirmationEmail.gs
Apps Script
// Sends a confirmation email when a form is submitted.
// Requires: Form Settings > Collect email addresses = ON
// Install trigger: onFormSubmit -> from this script, not from the editor's simple trigger

function onFormSubmit(e) {
  var respondentEmail = e.response.getRespondentEmail();

  if (!respondentEmail) {
    console.log('No respondent email captured. Check form collection setting.');
    return;
  }

  var subject = 'We received your submission';
  var body = 'Thanks for filling out the form. We will follow up within 2 business days.';

  GmailApp.sendEmail(respondentEmail, subject, body);
}

Need a variant? Gnaw writes a custom version from one sentence — fields, triggers, edge cases handled.

Walkthrough

The one setting that breaks everything if you skip it

Open your form, go to Settings, and find the "Collect email addresses" toggle under the Responses tab. It needs to be set to either "Verified" (Google-authenticated respondents only) or "Responder input" (they type it in). Without this, `e.response.getRespondentEmail()` returns an empty string every single time, and your script silently does nothing. The first time I hit this I spent twenty minutes staring at the trigger logs before I thought to check the form itself.

Once that setting is on, the email address is captured server-side at submission and attached to the FormResponse object. The script reads it off that object rather than trying to parse an answer from a specific question, so it works regardless of where the email field sits in your form layout.

Wiring up the script and the trigger

From your form, open the three-dot menu and choose "Script editor." Paste the code, rename the function if you like, then save. Do not use the editor's built-in "Run" button to test it — that fires the function without an event object and throws a TypeError immediately.

To install the trigger: in the Apps Script editor, click the clock icon (Triggers) in the left sidebar, then "Add Trigger." Set the function to `onFormSubmit`, the event source to "From form," and the event type to "On form submit." Google will ask you to authorize the script. This is an installable trigger, not the simple `onOpen` or `onEdit` kind (those are restricted to Sheets; installable triggers are how you hook into Forms events with full service access).

The authorization dialog mentions Gmail access because `GmailApp.sendEmail` sends from your account. Each submission will come from whatever Google account owns the script, not from a no-reply address.

Customizing the email body with form answers

If you want to include the respondent's actual answers in the confirmation, `e.response.getItemResponses()` returns an array of ItemResponse objects. Each one has `getItem().getTitle()` for the question text and `getResponse()` for what they typed.

Keep in mind that `getResponse()` returns a string for short-answer and paragraph questions, but an array for checkbox questions. If you concatenate without checking the type first, checkbox answers render as comma-separated values, which is usually fine for a confirmation email. The item type is available via `getItem().getType()` if you need to branch on it.

For a simple confirmation you probably do not need the answers at all. The pattern I use in production is a fixed subject line, a one-sentence acknowledgment, and a plain-text body. HTML emails via `GmailApp.sendEmail` require passing an options object with an `htmlBody` key as the fourth argument.

Want a custom version?

Describe your sheet and the rule you want. Gnaw writes the Apps Script — fields, triggers, edge cases — in one shot.

FAQ

4 questions
Why is getRespondentEmail() returning an empty string?
The form's "Collect email addresses" setting is off. Open Settings in the form editor, find the Collect email addresses option under Responses, and switch it to either Verified or Responder input. The script cannot read an email that the form never collected.
Can I use a simple onFormSubmit trigger instead of an installable one?
No. Simple triggers in Google Apps Script run with limited permissions and cannot call services like GmailApp that require authorization. An installable trigger (set up through the Triggers panel, not a reserved function name) runs under the account that authorized it and has full service access.
Will this send an email to every respondent or just the first one?
Every respondent, once per submission. The on-form-submit trigger fires once per submission event, and `e.response.getRespondentEmail()` returns the email for that specific submission. There is no loop needed; each submission is its own event.
Can I send from a different email address, like a shared inbox?
Not directly with GmailApp.sendEmail — that always sends from the account that owns the script. To send from a Gmail alias you control, pass a from option in the fourth argument options object: `{from: '[email protected]'}`. For a shared inbox you do not own, you would need to use the Gmail API with delegation, which is a more involved setup.
// one good script a week

Get a working Apps Script snippet in your inbox, weekly.