> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Email Connector

> Send templated email notifications and alerts from MQTT messages over SMTP

## Email Overview

The `EMAIL` connector sends templated emails in response to MQTT messages. It's the simplest way to turn a broker event — a critical alarm, a daily report, a user notification — into a message that reaches a person's inbox.

> [!TIP]
>
> **Like an auto-reply rule in your mailbox.** When a message lands on a topic you're watching, the connector fills in a template and sends the email for you — no manual step required.

### When to use it

* Alert an operations team the moment a critical alarm fires.
* Email a stakeholder a daily or shift report.
* Notify an individual user using an address pulled from the message payload.

***

Let's look at how to define an email connector, starting with the most common scenarios.

## Quick Start

> [tab] Critical alert
>
> Send an immediate alert to a fixed team address when a critical event arrives:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR CriticalAlerts WITH TYPE EMAIL
>     ADD SMTP_CONFIG
>         WITH HOST "smtp.gmail.com"
>         WITH PORT '587'
>         WITH USERNAME "alerts@company.com"
>         WITH PASSWORD "app-password-here"
>         WITH USE_TLS "true"
>     ADD EVENT criticalNotify
>         WITH SOURCE_TOPIC "alerts/critical/+"
>         WITH TEMPLATE_PATH "/templates/critical_alert.html"
>         WITH SUBJECT "CRITICAL: {value.json.alert_type}"
>         WITH RECIPIENT "ops-team@company.com"
> ```

> [tab] Dynamic recipient
>
> Send to an address taken from the message payload:
>
> ```lot wrap  theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR UserNotifications WITH TYPE EMAIL
>     ADD SMTP_CONFIG
>         WITH HOST "smtp.office365.com"
>         WITH PORT '587'
>         WITH USERNAME "noreply@company.com"
>         WITH PASSWORD "secure-password"
>         WITH USE_TLS "true"
>     ADD EVENT userNotify
>         WITH SOURCE_TOPIC "users/+/notifications"
>         WITH TEMPLATE_PATH "/templates/user_notification.html"
>         WITH SUBJECT "Hello {value.json.username}"
>         WITH RECIPIENT "{value.json.email}"
> ```

> [tab] Report with images
>
> Embed images (a logo, a chart) directly in the email:
>
> ```lot wrap  theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR ReportEmail WITH TYPE EMAIL
>     ADD SMTP_CONFIG
>         WITH HOST "smtp.company.com"
>         WITH PORT '587'
>         WITH USERNAME "reports@company.com"
>         WITH PASSWORD "password"
>         WITH USE_TLS "true"
>     ADD EVENT sendReport
>         WITH SOURCE_TOPIC "reports/daily"
>         WITH TEMPLATE_PATH "/templates/daily_report.html"
>         WITH SUBJECT "Daily Report - {value.json.date}"
>         WITH RECIPIENT "management@company.com"
>         WITH EMBED_RESOURCES
>             ADD "/images/logo.png"
>             ADD "/images/chart.png"
> ```

> [!NOTE]
>
> For Gmail, use an [App Password](https://support.google.com/accounts/answer/185833) instead of your regular password. Enable 2FA on your Google account first.

***

## SMTP Configuration

The `SMTP_CONFIG` block tells the connector which mail server to send through and how to authenticate.

> [accordion] Server Settings
>
> **HOST** `string` *required*
>
> SMTP server address (e.g., `smtp.gmail.com`, `smtp.office365.com`).
>
> **PORT** `integer` *required*
>
> SMTP port (typically 587 for TLS, 465 for SSL).
>
> **USE\_TLS** `boolean`
>
> Enable TLS encryption. Recommended: true.

> [accordion] Authentication
>
> **USERNAME** `string` *required*
>
> Email account to send from.
>
> **PASSWORD** `string` *required*
>
> Email password or app-specific password.

***

## Event Configuration

Each `ADD EVENT` block defines a trigger topic and the content of the email it sends.

> [accordion] Trigger & Routing
>
> **SOURCE\_TOPIC** `string`
>
> MQTT topic to trigger email sending.
>
> **DESTINATION\_TOPIC** `string`
>
> MQTT topic to publish send status.

> [accordion] Email Content
>
> **TEMPLATE\_PATH** `string`
>
> Path to HTML email template file.
>
> **SUBJECT** `string`
>
> Email subject line (supports placeholders).
>
> **RECIPIENT** `string`
>
> Email recipient address (supports placeholders).

### Template Placeholders

Subjects, recipients, and templates support placeholders that are filled in from the triggering message:

| Placeholder | Description |
| - | - |
| `{value}` | Full JSON payload as string |
| `{value.json.field}` | Single field from JSON |
| `{value.json.nested.field}` | Nested field access |

***

## Troubleshooting

> [accordion] Email Not Sending
>
> * Verify SMTP credentials are correct
> * For Gmail, ensure you're using an App Password
> * Check firewall allows outbound SMTP connections
> * Verify recipient email address is valid

> [accordion] Email Authentication Failed
>
> * Double-check USERNAME and PASSWORD
> * Ensure 2FA is enabled if using app passwords
> * Some providers require enabling "less secure apps" access
> * Check for account lockouts due to failed attempts

***

## Next Steps

> [card] [LoT Actions](https://docs.coreflux.org/v2.22/lot-language/actions/overview.md)
>
> Publish the MQTT events that trigger notifications.

> [card] [Data Storage Connectors](https://docs.coreflux.org/v2.22/lot-language/routes/data-storage/overview.md)
>
> Store MQTT data in databases.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.