terazone-smtp

n8n community node for sending secure emails via Terazone SMTP using raw TCP connection

Package Information

Released: 8 mo ago
Downloads: 18 weekly / 85 monthly
Latest Version: 0.1.1

Documentation

n8n-nodes-terazone-smtp

Custom n8n community node for sending secure emails with file attachments via Terazone SMTP using a direct raw TCP connection.

Why a Custom Node?

n8n's built-in Code node runs in a sandboxed environment that blocks direct TCP socket connections (net.createConnection). Terazone SMTP requires a raw TCP connection with no TLS and no authentication — a custom node is the only way to achieve this within n8n.

Installation

From npm (recommended)

  1. In your n8n instance, go to Settings > Community Nodes
  2. Click Install a community node
  3. Enter: n8n-nodes-terazone-smtp
  4. Click Install

The node will be available immediately — no restart needed.

Manual Installation

# Navigate to your n8n user directory
cd ~/.n8n

# Install the package
npm install n8n-nodes-terazone-smtp

# Restart n8n

Credentials Setup

  1. In n8n, go to Credentials > Add Credential
  2. Search for "Terazone SMTP"
  3. Fill in the following fields:
Field Type Required Default Description
SMTP Host string Yes — Terazone SMTP server hostname
SMTP Port number Yes 25 Terazone SMTP server port
From Address string Yes — Sender email address used in MAIL FROM
EHLO Domain string Yes mail.example.com Domain sent in the SMTP EHLO handshake
Connection Timeout (ms) number No 10000 Maximum time to wait for the SMTP connection

Node Parameters

Parameter Type Required Description
To Email string Yes Recipient email address. Comma-separated for multiple recipients.
Subject string Yes Email subject line.
Body string No Plain text email body.
Phone Numbers string No Comma-separated phone numbers. Appended to the subject as #phone# identifiers for tracking.
Attachment Source select Yes Choose between Binary Property or Base64 String.
Binary Property Name string Conditional Name of the binary property from a previous node (shown when source = Binary Property). Default: data.
Attachment File Name string Conditional File name including extension (shown when source = Base64 String).
Attachment Base64 Content string Conditional Base64-encoded file content (shown when source = Base64 String).

Usage Examples

Example 1: Send a simple test email

Use a Manual Trigger connected to the Terazone Secure Mail node with these settings:

  • To Email: recipient@example.com
  • Subject: Test from n8n
  • Body: This is a test email
  • Phone Numbers: 0501234567
  • Attachment Source: Base64 String
  • Attachment File Name: test.txt
  • Attachment Base64 Content: SGVsbG8gV29ybGQ=

The SGVsbG8gV29ybGQ= value is "Hello World" in base64. The resulting subject will be: Test from n8n #0501234567#.

Example 2: Send a PDF from an HTTP Request

[Manual Trigger] → [HTTP Request] → [Terazone Secure Mail]
  1. HTTP Request node: download a PDF with Response Format set to File
  2. Terazone Secure Mail node:
    • Attachment Source: Binary Property
    • Binary Property Name: data

The node automatically reads the file name and base64 content from the binary data.

Example 3: Dynamic input from previous node

All parameters support n8n expressions. Connect a Set node or any data source:

  • To Email: {{ $json.toEmail }}
  • Subject: {{ $json.subject }}
  • Body: {{ $json.body }}
  • Phone Numbers: {{ $json.phoneNumbers }}
  • Attachment File Name: {{ $json.attachmentFileName }}
  • Attachment Base64 Content: {{ $json.attachmentBase64 }}

Sample input JSON for testing:

{
  "toEmail": "test@example.com",
  "subject": "Monthly report for January 2025",
  "body": "Hello, please find the attached report.",
  "phoneNumbers": "0501234567",
  "attachmentFileName": "test-result.txt",
  "attachmentBase64": "SGVsbG8gV29ybGQ="
}

Output

On success the node outputs:

{
  "success": true,
  "to": ["recipient@example.com"],
  "subject": "Test from n8n #0501234567#",
  "attachmentFileName": "test.txt"
}

On failure (with Continue On Fail enabled):

{
  "success": false,
  "error": "SMTP connection timed out after 10000ms"
}

How It Works

The node opens a raw TCP socket to the Terazone SMTP server and performs the standard SMTP command sequence:

Client connects via TCP
Server: 220 ...
Client: EHLO mail.example.com
Server: 250 OK
Client: MAIL FROM: <sender@example.com>
Server: ... Sender OK
Client: RCPT TO: <recipient@example.com>
Server: ...
Client: DATA
Server: ... Start mail input
Client: [MIME headers + multipart body with base64 attachment]
Client: .
Server: ... Queued mail for delivery
Client closes connection

Key details:

  • No TLS — plain TCP connection
  • No authentication — the Terazone relay does not require credentials
  • MIME multipart — attachment sent as application/octet-stream with base64 encoding
  • UTF-8 support — subject and file name are encoded using RFC 2047 Base64 (=?UTF-8?B?...?=) for Hebrew and other non-ASCII characters
  • Timeout — configurable, defaults to 10 seconds

Troubleshooting

Issue Solution
Node doesn't appear in n8n Restart n8n after manual installation. For npm install via UI, it should appear immediately.
SMTP connection timed out Verify network connectivity from the n8n server to the SMTP host:port. Check firewalls.
SMTP connection error: ECONNREFUSED SMTP server is down or port is blocked by a firewall.
Garbled subject or filename This is typically a mail client display issue. The node uses standard RFC 2047 Base64 UTF-8 encoding.
Continue On Fail shows error JSON This is expected behavior — the node catches the error and outputs it as data instead of stopping the workflow.

Compatibility

  • n8n: >= 1.0.0
  • Node.js: >= 18
  • Runtime dependencies: None (uses only Node.js built-in modules net and readline)

License

MIT

Discussion