Send automated emails with n8n: SMTP, Gmail, and templates

Choose Gmail OAuth or SMTP, configure encryption, build reusable templates for every recipient, and check scheduled sends and error workflows.

n8n email automation: SMTP, Gmail OAuth, and HTML templates
How to send automated emails with n8n using the Send Email SMTP node, the Gmail OAuth node, and reusable HTML templates.

TL;DR: Send automated emails with n8n using Send Email for SMTP or Gmail for OAuth, then map each input item into a tested HTML template.

For a digest or confirmation to arrive, the sender needs valid credentials and the expected input fields. Gmail setup differs between n8n Cloud and self-hosting, and a template that reads only the first item can silently omit other recipients.

Checked 3 November 2026 against current n8n and Google documentation; the template transformation was tested locally, without sending email.

Which n8n email node should you use?

Choose Send Email when your provider offers a compatible SMTP account. Choose the Gmail node when you need Gmail API operations such as sending, replying or managing messages. Both support HTML and attachments; neither removes the provider's sending limits.

RouteCredentialBest for
Send Email.SMTP host, user, password and encryption settings.A provider-approved SMTP relay or mailbox.
Gmail on n8n Cloud.Managed OAuth2 sign-in, or custom OAuth2 if preferred.Gmail with managed Google authentication.
Gmail on self-hosted n8n.Your own Google OAuth client and consent configuration.Gmail API access on infrastructure you operate.

For infrastructure setup, use the self-hosted n8n walkthrough. Choose credentials for the service you use; self-hosted n8n can use either route when the provider permits it.

How do you set up Gmail SMTP credentials in n8n?

For n8n's documented Gmail SMTP route, enable 2-Step Verification and generate an app password. Google's app-password guidance explains that organizational restrictions, Advanced Protection or security-key-only verification can make the option unavailable. Google recommends Google sign-in when the app supports it; use the Gmail OAuth route if appropriate.

  1. Open your Google Account's App passwords page, name the app and create a password.
  2. Create an SMTP account credential from the Send Email node.
  3. Set Host to smtp.gmail.com, User to your full Gmail address and Password to the generated app password.
  4. Use port 465 with SSL/TLS on, or 587 with SSL/TLS off and STARTTLS enabled.

The SMTP credential reference distinguishes implicit TLS on 465 from STARTTLS on 587. For 587, leave Disable STARTTLS off. Turning SSL/TLS off for that port enables the upgrade path; it is not advice to send an unencrypted password. Match your provider's requirements rather than assuming one port is universally safer or less blocked.

Conceptual SMTP handshake lanes:465 uses implicit TLS with SSL/TLS on;587 upgrades through STARTTLS with SSL/TLS off and Disable STARTTLS off.
Use 465 with implicit TLS or 587 with STARTTLS, matching the SMTP credential toggles to the provider requirements rather than guessing.

How do you set up the n8n Gmail node with OAuth?

The Google OAuth2 single-service guide separates managed and custom credentials. On n8n Cloud, Gmail supports Managed OAuth2: select the credential and use Sign in with Google. Self-hosted n8n needs Custom OAuth2.

  1. Create a Google Cloud project and enable the Gmail API.
  2. Configure the consent audience and add your account as a test user when required.
  3. Create a Web application OAuth client and copy the OAuth Redirect URL shown in n8n into its authorized redirect URIs.
  4. Enter the Client ID and Client Secret in n8n, sign in and save the credential.

Set Gmail's Resource to Message, Operation to Send, and Email Type to HTML. Map To, Subject and Message from your prepared item. Store secrets in credentials, not template text.

For an external Google app in Testing, a refresh token normally expires after seven days when Gmail scopes are involved. Google's refresh-token rules explain the profile-only exception and other expiry causes. Review publishing status and applicable verification requirements before relying on a long-running schedule. A redirect mismatch needs an exact callback match; the n8n OAuth callback diagnosis covers the wider access path.

Step 1: How do you build an n8n email automation workflow?

Build a digest as Schedule Trigger, data retrieval, summary preparation and Send Email or Gmail. Use the appropriate Google Sheets, database or HTTP Request node for the source. Prepare one summary item for a digest, or one item per recipient for personalized messages.

Set the Schedule Trigger to the desired daily time and explicitly set the workflow timezone, for example Etc/UTC for 08:00 UTC. Save and publish the workflow. An unspecified timezone can inherit the instance setting and shift the intended send time.

For a summary item containing numeric signups and revenue, set Send Email's Email Format to HTML and use expressions in the body:

<h2>Daily summary {{ $now.toFormat('yyyy-MM-dd') }}</h2>
<p>Signups: {{ $json.signups }}</p>
<p>Revenue: {{ $json.revenue }}</p>

Confirm the incoming fields and their types in the execution data. For a batch, check that each item carries its own recipient; joining unrelated rows into one item changes the delivery design.

Step 2: How do you build reusable HTML email templates in n8n?

Use a JavaScript Code node in Run Once for All Items mode to prepare one message per input. The Code node reference documents this mode. Map all items instead of reading only $input.first(), and escape variable text before inserting it into HTML.

const escapeHtml = value => String(value ?? '').replace(
  /[&<>"']/g,
  char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;',
    '"': '&quot;', "'": '&#39;' }[char])
);

return $input.all().map((item, index) => {
  const { email, name = 'there', plan = 'selected' } = item.json;
  if (typeof email !== 'string' || !email.trim()) {
    throw new Error('Missing recipient email');
  }
  return {
    json: {
      to: email.trim(),
      subject: 'Welcome',
      body: `<h2>Hi ${escapeHtml(name)}</h2>
<p>Your plan: <strong>${escapeHtml(plan)}</strong>.</p>`
    },
    pairedItem: { item: index }
  };
});

Set the sender node's recipient to {{ $json.to }}, Subject to {{ $json.subject }} and HTML body to {{ $json.body }}. The snippet checks presence, not full address validity; use a trusted recipient source and your own validation. Escaping here covers HTML text content, not arbitrary URLs or attributes.

Two input records map to two separate recipient messages; the second name containing angle brackets and ampersand is escaped as HTML text.
Map every input item to its own message and escape variable HTML text, preserving the intended recipient throughout the template transformation.

What are the most common n8n email automation patterns?

A scheduled digest aggregates source data before sending. A form confirmation validates the submitted address and maps one form item to one message. An If node can choose different templates for trial and paid plans.

For error alerts, start a separate automation with Error Trigger, then Send Email, and select it under Error workflow in the source's settings. The error-workflow guide requires that trigger. The Error Trigger reference also distinguishes automatic failures from manual test runs. A lone sending node cannot receive these failure events.

Failed automatic source execution invokes the selected Email alerts workflow, starting with Error Trigger and then Send Email; manual tests do not launch it.
An automatic failure invokes the configured error workflow, which must begin with Error Trigger before a sending node can deliver an alert.

How do you fix common n8n email send failures?

Separate credential rejection, transport failure and delivery failure. Check app-password eligibility or revocation for SMTP authentication errors. For refused connections or timeouts, verify hostname, port, DNS and network access; a provider block is one possibility. An HTTPS mail API needs its supported integration, not merely a different SMTP hostname.

Check the receiving mailbox even after the sender node succeeds. Check provider responses, bounces and sending-domain authentication. Inspect the per-node execution data before retrying: if an earlier send succeeded, replaying the workflow can create duplicate email.

Step 3: How do you verify the email workflow before publishing?

  1. Connect the selected SMTP or OAuth credential.
  2. Check the workflow timezone and trigger configuration.
  3. Run the template with one item and two different recipients.
  4. Inspect escaped names, subject, body and recipient mappings.
  5. Send one approved test message and inspect the receiving mailbox.
  6. Publish the workflow and verify its next scheduled execution.

FAQ

Can you send attachments with the n8n Send Email node?

Yes. Set Attachments to the actual incoming binary property name, such as data; multiple properties use comma-separated names. Verify the file exists in the input before sending.

Can you send to multiple recipients?

Send Email accepts comma-separated recipients and has CC and BCC options. For personalized content, keep separate items and review recipient privacy before combining addresses.

Is there a daily send limit on Gmail SMTP?

Yes. Consult Google's personal Gmail limits and Workspace limits for your account and sending route. Switching n8n nodes does not remove those limits.

Can n8n schedule an email to send later?

Use Schedule Trigger for recurring sends or a Wait node before delivery for a delayed workflow. Verify the timezone and publication state for scheduled runs.

What n8n version added HTML email support?

The current Send Email documentation supports Text, HTML and Both. This guide does not assert a first supporting version; check your installed node's options instead of relying on the old n8n 1.x reference.