Gmail Alias Sender with Attachment Support via API - n8n Workflow

Use this advanced n8n workflow to send emails from custom Gmail aliases with optional attachments by directly interacting with the Gmail API. Essential for robust programmatic emailing.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers needing robust email sending capabilities requiring specific 'From' addresses.

  • Automators who require custom Gmail aliases for different communication types.

  • Technical users building complex n8n templates that need granular control over email payloads.

  • Teams centralizing email automation using n8n and relying on high-fidelity attachments.

Overview

This powerful n8n workflow addresses the limitations encountered when utilizing the standard Gmail n8n node for advanced use cases, specifically when defining custom 'From' aliases or handling complex, programmatic attachments. By utilizing the Gmail API directly through an advanced HTTP Request n8n node, this n8n automation provides granular control over the email payload. This allows users to reliably define the sender name, reply-to address, and seamlessly attach files downloaded from external URLs, all while maintaining the integrity of the base64-encoded MIME structure. This is an essential n8n workflow for high-volume or highly customized email delivery.

How it Works

The entire process begins with the Webhook Trigger, which serves as the entry point for the n8n workflow, typically receiving a POST request containing all email configuration data (recipient, subject, body, and potentially an array of attachment URLs). The flow first determines if attachments are provided using the If Attachments n8n node, checking the file_urls property in the incoming body. If URLs exist, the Split Out Attachments node separates them, allowing the Download Attachments n8n node (an HTTP Request) to fetch the binary data for each file. All required data then flows into the core component: the Format Email Payload n8n node (a Code node). This crucial step validates input, processes all binary data found in the previous nodes into a list of attachments, and programmatically constructs the complete MIME message in the RFC2822 standard. This message, which includes the HTML body and base64-encoded attachments, is then base64url encoded, which is the specific format required by the Gmail API. Finally, the Send Gmail as Alias HTTP Request n8n node executes the POST call to the Gmail API using OAuth2 credentials, successfully delivering the email from the specified custom alias. This comprehensive n8n node chain ensures robust email delivery.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n canvas using the 'New' -> 'Import from JSON' option.

  2. Configure the Webhook Trigger: The Webhook Trigger n8n node is configured with the path /send-gmail-as-alias. Activate the n8n workflow and copy the full production webhook URL.

  3. Set up Gmail Credentials: In the Send Gmail as Alias n8n node (HTTP Request), ensure you select or create an OAuth2 credential for Gmail. This credential must be authorized to use the gmail.send scope and must belong to an account that has permission to send emails from the desired custom alias. Note that sending from an alias requires proper configuration within your Gmail settings.

  4. External Integration: Call the copied webhook URL from your external application, ensuring your POST request body includes the necessary fields like toEmail, subject, htmlBody, and optionally, file_urls (an array of public file URLs for attachments).

Node Details


  • Webhook Trigger: The starting n8n trigger. Configured to listen for POST requests at /send-gmail-as-alias to initiate the n8n workflow execution.

  • If Attachments (n8n node): Core logic flow control. Checks if the incoming JSON body contains file_urls to determine if the attachment download path should be taken.

  • Split Out Attachments (n8n node): If multiple file URLs are present, this node splits the incoming item into multiple items, one for each URL, allowing the subsequent HTTP Request to process attachments individually.

  • Download Attachments (HTTP Request n8n node): Downloads the actual binary file content from the URL provided in the input item. The resulting binary data is stored for processing by the next n8n node.

  • Format Email Payload (Code n8n node): This essential n8n node handles all payload preparation. It validates inputs, converts binary data into base64 attachments, constructs the RFC2822 MIME message (handling multipart/mixed content), and base64url encodes the entire message required by the Gmail API.

  • Send Gmail as Alias (HTTP Request n8n node): The final action. This n8n node uses the Gmail API's messages/send endpoint, leveraging OAuth2 credentials and the raw parameter to send the meticulously constructed, base64url encoded email payload, enabling the use of custom aliases.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
Jacob @ vwork Digital
Jacob @ vwork Digital

Featured*