SMTP Destination

Send messages as email notifications via SMTP for alerts and clinical communication.

Overview

The SMTP destination sends processed messages as emails using the Simple Mail Transfer Protocol. This is commonly used in healthcare for sending alert notifications (critical lab results, ADT events), delivering formatted reports to clinical staff, or routing processed data summaries to administrative recipients. The destination supports TLS encryption and SMTP authentication.

Configuration

Define an SMTP destination in your root intu.yaml under the destinations key:

yaml
# intu.yaml
destinations:
  critical-alerts:
    type: smtp
    smtp:
      host: smtp.hospital.org
      port: 587
      from: intu-alerts@hospital.org
      to:
        - lab-oncall@hospital.org
        - chief-pathologist@hospital.org
      subject: "Critical Lab Result Alert - ${patientId}"
      auth:
        username: ${SMTP_USER}
        password: ${SMTP_PASS}
      tls:
        enabled: true

Properties

host string required
SMTP server hostname or IP address.
port int optional
SMTP server port. Common values: 25 (unencrypted), 465 (implicit TLS), 587 (STARTTLS). Defaults to 587.
from string required
Sender email address. This appears in the "From" header of outgoing emails.
to string[] required
List of recipient email addresses. At least one recipient is required.
subject string required
Email subject line template. Supports ${VAR} interpolation from message headers and environment variables.
cc string[] optional
List of CC recipient email addresses.
bcc string[] optional
List of BCC recipient email addresses.
content_type string optional
MIME type for the email body. One of: text/plain, text/html. Defaults to text/plain.

Authentication

auth.username string optional
SMTP authentication username. Omit for unauthenticated relay.
auth.password string optional
SMTP authentication password. Use ${VAR} to reference environment variables.

TLS

tls.enabled bool optional
Enable TLS (STARTTLS on port 587, implicit TLS on port 465). Defaults to true.
tls.insecure_skip_verify bool optional
Skip TLS certificate verification. Defaults to false.

Full Example

Monitor HL7v2 ORU messages for critical lab results and send email alerts to the on-call laboratory team.

Root Configuration

yaml
# intu.yaml
destinations:
  critical-lab-alert:
    type: smtp
    smtp:
      host: smtp.hospital.org
      port: 587
      from: intu-critical-alerts@hospital.org
      to:
        - lab-oncall@hospital.org
        - pathology-team@hospital.org
      cc:
        - lab-supervisor@hospital.org
      subject: "CRITICAL: Abnormal Lab Result - Patient ${patientId}"
      content_type: text/html
      auth:
        username: ${SMTP_USER}
        password: ${SMTP_PASS}
      tls:
        enabled: true

Channel Configuration

yaml
# channels/critical-alerts/channel.yaml
name: critical-alerts
description: Email alerts for critical lab results

source:
  type: tcp
  tcp:
    port: 6665
    mode: mllp

destinations:
  - critical-lab-alert

Destination Transformer

typescript
// channels/critical-alerts/transformer.ts
import { Message, Context } from "@intu/sdk";

export default function transform(msg: Message, ctx: Context): Message | null {
  const hl7 = msg.body;
  const pid = hl7.segments?.find((s: any) => s.name === "PID");
  const obxSegments = hl7.segments?.filter((s: any) => s.name === "OBX") ?? [];

  const criticalResults = obxSegments.filter(
    (obx: any) => obx.fields[8]?.components[0] === "C"
  );

  if (criticalResults.length === 0) {
    ctx.logger.info("No critical results found, skipping alert");
    return null;
  }

  const patientId = pid?.fields[3]?.components[0] ?? "UNKNOWN";
  const patientName = `${pid?.fields[5]?.components[1] ?? ""} ${pid?.fields[5]?.components[0] ?? ""}`.trim();

  const resultsHtml = criticalResults
    .map((obx: any) => {
      const testName = obx.fields[3]?.components[1] ?? "Unknown Test";
      const value = obx.fields[5]?.components[0] ?? "";
      const units = obx.fields[6]?.components[0] ?? "";
      const refRange = obx.fields[7]?.components[0] ?? "";
      return `
        ${testName}
        ${value} ${units}
        ${refRange}
      `;
    })
    .join("\n");

  const emailBody = `
    

Critical Lab Result Alert

Patient: ${patientName} (MRN: ${patientId})

Time: ${new Date().toISOString()}

${resultsHtml}
Test Result Reference Range

This is an automated alert from the intu integration engine. Please review immediately.

`; return { ...msg, body: emailBody, headers: { ...msg.headers, patientId, }, }; }
Filtering The transformer can return null to suppress the email for non-critical results. Only messages that pass through the transformer with a non-null return value are delivered to the SMTP destination.