Basic mail merge script for Gmail (using Google Apps Script)
Published: 2021-04-12 15:04:32

---
title: Basic mail merge script for Gmail (using Google Apps Script)
published: true
description: Learn how to send hundreds of emails in Gmail by building your very own mail merge Gmail script.
tags: 
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--btLWiJrP--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzlsokcbu38patfgc4ho.png
canonical_url: https://mailmeteor.com/mail-merge-gmail/script
---

Sending mass emails from Gmail is sometimes seen as a challenge. I can tell you it's not! In this article we'll look at the basics of building a mail merge script for Gmail and how it can fit your email marketing needs.

First, here's what you need to send emails in bulk with Gmail:

- a Gmail (or Google Workspace) account
- a list of contacts
- a template of the emails you want to send
- basic development skills

Now let's see the 6 steps to reproduce to create your Google script to send emails.

## Tutorial: Building a mail merge script for Gmail

1. Open [Google Apps Script](https://script.google.com/)
2. Click on the "**New project**" button to create a new project.
3. You should now see the script editor.
   ![Google Apps Script editor](https://mailmeteor.com/assets/img/blog/mail-merge-gmail/mail-merge-gmail-script-gas-editor.png)
4. From the editor, copy and paste the following script:
   {% gist https://gist.github.com/Frenchcooc/a2d12a7c663c6c432bb03ff3ea67b20d %}
   Update the `recipients` variable with your list of recipients. Also update the `template` subject and content to make it fit your needs
5. Click on "**Save**" to save your changes
6. Then click on "**▶️ Run**" to send your emails.

> _Note: the first time you use this script it will ask for the permission to send emails on your behalf. Then it won't ask you again._

Emails are usually immediately delivered, but sometimes it takes a few seconds. Check your ["Sent" folder in Gmail](https://mail.google.com/mail/#sent) to confirm that all emails have been sent! As you will see, all your recipients receive a unique email sent from your email address. You don't need to use _bcc_ or any other techniques.

## Conclusion

Some say that it's impossible to send emails in bulk with Gmail. It's totally untrue. Of course, this is a very basic macro for Google Sheets to send lots of emails with Gmail. You might need to adapt it a little bit more, but thanks to Google Apps Script you can do lot of things.

Before you go, here are two things to keep in mind when using Gmail as an email marketing tool:

1. **Be sure to abide by [Gmail bulk senders guidelines](https://support.google.com/mail/answer/81126?hl=en).** Especially, note that you are limited to send a reasonable amount of emails per day. If you have a `@gmail.com` email address, you can send at most 500 emails/day while with a Google Workspace account, you sending limit hits 2000 emails per day. That's probably well enough for 99% of Gmail users, but it's good to have in mind those limits.
2. If you are looking for more a advanced script, for example that let you send personalized emails (e.g. `Hi {{ firstname }}`), I'd recommend you to use a Gmail mail merge tool such a [Mailmeteor](https://mailmeteor.com?utm_source=devto&utm_medium=blogpost&utm_campaign=mail-merge-gmail) that does it for you. It already handles personalization, as well as dozens of features from attachments to aliases. Learn more about the [features and benefits of Mailmeteor here](https://mailmeteor.com/features?utm_source=devto&utm_medium=blogpost&utm_campaign=mail-merge-gmail).


This article is part of an extended guide on [Mail merge in Gmail (2021)](https://mailmeteor.com/mail-merge-gmail/?utm_source=devto&utm_medium=blogpost&utm_campaign=mail-merge-gmail). If you want to learn much more, go check it out!