To send email from Google Sheets, open Extensions, Apps Script in the sheet, write a function that reads rows and calls MailApp.sendEmail(), then run it manually or attach a trigger. The message is sent from the Google account that authorised the script, and every send counts against Google's daily quota.
That is fine for internal notifications and small mail merges. It is the wrong tool for large campaigns or customer-facing mail at volume, because the quota is small, you cannot choose your own sending domain or IP, and you get little delivery data. This guide gives a working script, explains the limits, and shows how to switch to an email API with UrlFetchApp when you outgrow MailApp.
MailApp, GmailApp or an API: which to use
| Option | What it does | Best for | Limits |
|---|---|---|---|
| MailApp | Sends email only; no inbox access | Notifications and simple mail merges | Daily recipient quota; sends as the script owner |
| GmailApp | Sends and also reads, labels and drafts in Gmail | Scripts that need to read replies or create drafts | Needs broader Gmail permission; same quota family |
| UrlFetchApp to an email API | HTTPS call to a provider | Volume, your own domain, delivery events | Provider limits and cost; URL fetch quota in Apps Script |
| Built-in SMTP | Not available | Nothing | Apps Script has no SMTP client |
Prefer MailApp when you only need to send, because it asks for the narrowest permission. Google changes quotas and permission prompts from time to time, so confirm the current numbers in Google's Apps Script quotas documentation instead of relying on any figure quoted in a blog post.
A working script: send one email per row and mark it sent
Set up the sheet with a header row: Email, Name, Message and Status. The script below skips rows already marked sent, which makes it safe to re-run after an error or after the quota resets.
function sendRows() {
const sheet = SpreadsheetApp.getActiveSheet();
const rows = sheet.getDataRange().getValues();
const header = rows[0];
const col = (name) => header.indexOf(name);
const iEmail = col('Email'), iName = col('Name'), iMsg = col('Message'), iStatus = col('Status');
for (let r = 1; r < rows.length; r++) {
if (rows[r][iStatus]) continue; // already handled
if (MailApp.getRemainingDailyQuota() < 1) {
Logger.log('Quota exhausted, stopping at row ' + (r + 1));
break;
}
const to = String(rows[r][iEmail]).trim();
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(to)) {
sheet.getRange(r + 1, iStatus + 1).setValue('INVALID');
continue;
}
try {
MailApp.sendEmail({
to: to,
subject: 'Hello ' + rows[r][iName],
htmlBody: '<p>Hi ' + rows[r][iName] + ',</p><p>' + rows[r][iMsg] + '</p>',
name: 'Acme Team',
replyTo: '[email protected]',
});
sheet.getRange(r + 1, iStatus + 1).setValue('SENT ' + new Date().toISOString());
} catch (e) {
sheet.getRange(r + 1, iStatus + 1).setValue('ERROR: ' + e.message);
}
Utilities.sleep(200); // be gentle with the service
}
}On the first run Google asks you to authorise the script. Review the requested scopes before accepting: sending email on your behalf is a significant permission, so only run scripts you wrote or have read. If the sheet is shared, remember that anyone with edit access can change the script's inputs, and the mail goes out under your name.
Run it automatically with triggers
- In the Apps Script editor open Triggers (the clock icon).
- Choose Add Trigger, select
sendRowsas the function. - Pick an event source: Time-driven for a schedule, From spreadsheet for on-edit or on-form-submit.
- Save and authorise. Installable triggers run as the account that created them.
- Check Executions afterwards for errors and run times.
Use an installable trigger rather than a simple onEdit, because simple triggers cannot call services that need authorisation, and sending mail is one of them. Keep each run short: Apps Script limits how long a single execution can run, so batch large lists across several runs by relying on the Status column.
Understand the quota
MailApp and GmailApp share a daily quota that counts recipients, not messages: one email to three addresses uses three. The allowance differs between free consumer accounts and Google Workspace accounts, and is reset on a rolling basis. Call MailApp.getRemainingDailyQuota() before sending, as the script above does, and stop cleanly when it reaches zero. Google may also impose other limits, for example on attachment size or on the number of recipients per message, and can block accounts that send what it sees as abusive volume.
Because the messages are sent through Google's own infrastructure with Google's authentication on the account's domain, delivery for small volumes is usually good. At scale it is not designed for marketing mail: there is no unsubscribe handling, no bounce suppression list and no per-message event stream. The rules for bulk senders still apply to you; see bulk sender requirements. For the practical limits of using a mailbox for newsletters, see newsletters from Gmail and Outlook.
Switch to an email API with UrlFetchApp
When you need more volume, a custom domain with its own authentication, or bounce and complaint data, call a transactional email API over HTTPS. Apps Script supports this with UrlFetchApp.fetch(). Store the key in script properties (Project Settings, Script Properties), not in the code and not in a sheet cell. The field names in the payload are illustrative, so confirm the schema in the API reference.
function sendViaApi(to, subject, html) {
const key = PropertiesService.getScriptProperties().getProperty('MAIL_API_KEY');
const res = UrlFetchApp.fetch('https://api.migosmtp.com/v1/send', {
method: 'post',
contentType: 'application/json',
headers: { Authorization: 'Bearer ' + key },
payload: JSON.stringify({
from: 'Acme <[email protected]>',
to: to,
subject: subject,
html: html,
}),
muteHttpExceptions: true,
});
const code = res.getResponseCode();
if (code < 200 || code >= 300) {
throw new Error('API error ' + code + ': ' + res.getContentText());
}
return JSON.parse(res.getContentText());
}Replace the MailApp.sendEmail call in the earlier script with sendViaApi. Two things change: you must verify the From domain with SPF and DKIM (see authenticating your sending domain), and you get webhooks for bounces and complaints that you can write back into the sheet. The trade-offs between the two approaches are explained in SMTP versus API.
Templates, attachments and sender identity
Hard-coding the message in the script makes it hard to maintain. Keep the template in a sheet tab or a Google Doc, and substitute placeholders such as {{Name}} with a simple string replace. Always provide both body (plain text) and htmlBody so clients that cannot render HTML still show a readable message. See personalisation variables and fallbacks for handling missing values.
To attach a file, fetch it from Drive with DriveApp.getFileById(id).getBlob() and pass it in the attachments array. Keep attachments small, since large files raise failure rates and may breach receiver limits. The visible sender is the Google account that owns the script; the name option changes only the display name, and replyTo sets where replies go. You cannot send as an arbitrary address with MailApp, which is a feature, not a limitation, for anti-spoofing.
Good practice for spreadsheet-driven mail
- Send only to people who expect to hear from you and keep proof of consent for marketing lists.
- Include a working unsubscribe route and honour requests at once for anything promotional.
- Remove hard-bounced addresses from the sheet; do not retry them.
- Escape or validate values that come from cells before they enter HTML or headers.
- Test with a small range or your own addresses first, then run the full list.
- Do not store API keys, passwords or personal data you do not need in the sheet.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Service invoked too many times: email | Daily quota reached | Wait for the reset, send fewer recipients, or move to an API |
| You do not have permission to call MailApp.sendEmail | Script not authorised, or run from a simple trigger | Run once manually to authorise; use an installable trigger |
| Invalid email error | Blank or malformed cell value | Validate addresses before sending, as in the script |
| Exceeded maximum execution time | Too many rows in one run | Process in batches and rely on the Status column |
| Mail lands in spam | Repetitive content or a flagged sender | Vary and shorten content; see spam troubleshooting |
| Replies go to the wrong address | replyTo not set | Pass replyTo in the options object |
When to move on
Stay with MailApp while volume is small and the recipients are internal or expecting your messages. Move to an email API when you hit the quota, need your own sending domain, need to know what bounced, or must send customer-facing transactional mail reliably.
Outgrown MailApp? Send from Apps Script through the MigoSMTP email API with a scoped key and delivery events.
References and further reading
Frequently asked questions
How do I send email from Google Sheets automatically?
Write an Apps Script function using MailApp.sendEmail and attach an installable time-driven or form-submit trigger.
What is the difference between MailApp and GmailApp?
MailApp only sends email and needs narrower permission. GmailApp can also read, label and draft messages in the mailbox.
What is the daily email limit in Apps Script?
It depends on the account type and changes over time. Call MailApp.getRemainingDailyQuota() and check Google documentation for current numbers.
Can Apps Script send mail over SMTP?
No, it has no SMTP client. Use MailApp, GmailApp or an HTTPS email API through UrlFetchApp.
Is Google Sheets suitable for bulk marketing email?
Not really. The quota is small and there is no suppression or unsubscribe handling, so use a proper sending service for campaigns.