Sending Emails from an Alias using Google Apps Script
In the realm of automation and productivity, Google Apps Script stands out as a powerful tool. One of its standout features is the ability to send emails, including the flexibility to use an alias instead of your primary Gmail address. This guide will walk you through the process of sending emails from an alias using Google Apps Script.
Understanding Aliases in Gmail
Before we dive into the script, let's ensure you understand what aliases are in Gmail. An alias is an alternative email address that you can use to send messages. For instance, if your primary email is [johndoe@gmail.com](mailto:johndoe@gmail.com), you can add an alias like [johndoe.alias@gmail.com](mailto:johndoe.alias@gmail.com) and use it to send emails.
Setting Up Your Alias
Before you can use an alias in your Google Apps Script, you need to set it up in your Gmail account.

- Go to your Google Account settings.
- Click on "Email" in the left-hand menu.
- Under "Email aliases," click on "Add another email address."
- Enter your alias and click "Continue."
- Follow the prompts to verify your alias.
Google Apps Script: Sending Emails from an Alias
Now that you have your alias set up, let's write a Google Apps Script to send an email using that alias.
Using GmailApp Service
The GmailApp service in Google Apps Script provides methods to send emails. Here's a simple script to send an email from your alias:
function sendEmailFromAlias() {
var alias = "johndoe.alias@gmail.com";
var subject = "Test Email from Alias";
var body = "This is a test email sent from an alias using Google Apps Script.";
GmailApp.sendEmail(alias, subject, body);
}
Setting the 'From' Address
By default, the script will send the email from your primary Gmail address. To send it from your alias, you need to set the 'from' address. Here's how you can modify the script:

function sendEmailFromAlias() {
var alias = "johndoe.alias@gmail.com";
var subject = "Test Email from Alias";
var body = "This is a test email sent from an alias using Google Apps Script.";
GmailApp.sendEmail({
'from': alias,
'to': 'recipient@example.com',
'subject': subject,
'body': body
});
}
Troubleshooting: "You do not have permission to send mail as this alias" Error
If you're encountering the error "You do not have permission to send mail as this alias," it's likely because you haven't granted the necessary permissions. Here's how to fix this:
- Go to your Gmail account settings.
- Click on "Accounts and Import" in the top navigation.
- Under "Send mail as," click on "Add another email address you own."
- Enter your alias and follow the prompts to grant permissions.
Best Practices and Limitations
While sending emails from an alias using Google Apps Script is a powerful feature, there are a few best practices and limitations to keep in mind:
- Ensure you have the necessary permissions to send emails as the alias.
- Be mindful of email sending limits to avoid being flagged for spamming.
- Consider using the MailApp service for more advanced email functionality, such as attachments and HTML bodies.
In conclusion, sending emails from an alias using Google Apps Script is a versatile feature that can enhance your automation workflows. By understanding how to set up your alias and use the GmailApp service, you can unlock new levels of productivity and efficiency.