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

# Sending an email

> To use the notification plugin for sending emails with attachments, you must define the same topic configuration as for sending regular notifications. A notification template must be created, and the corresponding Kafka topics must be defined.

> [!TIP]
>
> Before proceeding, make sure you understand [how to send basic notifications](https://docs.flowx.ai/6.x/docs/platform-deep-dive/core-extensions/content-management/notifications-plugin/sending-a-notification.md).

> [!NOTE]
>
> For **new processes**, use the [Send Notification action](https://docs.flowx.ai/6.x/docs/building-blocks/actions/send-notification-action.md) instead. It provides typed configuration fields and validation, and runs through the same notification backend. This Kafka-based guide is preserved for existing flows and advanced cases where the payload must be hand-crafted.

## Overview

This guide explains how to send emails with document attachments through the notification plugin. You'll learn how to:

* Configure email templates with dynamic content
* Reference generated documents as attachments
* Implement the complete email notification flow in your processes

## Prerequisites

1. A configured notification template (see [Managing notification templates](https://docs.flowx.ai/6.x/docs/platform-deep-dive/core-extensions/content-management/notifications-plugin/managing-notification-templates.md))
2. Properly defined Kafka topics for the notification plugin
3. Files to attach (such as generated documents or uploaded files)

## Implementing email notifications with attachments

Let's walk through a common scenario: sending a customer a copy of their account details document via email.

![Email notification process flow](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/send_an_email.png)

> [card] [Document Generation](https://docs.flowx.ai/6.x/docs/platform-deep-dive/core-extensions/content-management/documents-plugin/generating-from-html-templates.md)
>
> If you need to generate the document first, see the document generation guide.

### Understanding document references

When you generate a document, as explained in the [Generating documents](https://docs.flowx.ai/6.x/docs/platform-deep-dive/core-extensions/content-management/documents-plugin/generating-from-html-templates.md) guide, you need to reference two key pieces of information:

1. **minioPath**: The storage location of the generated document
2. **documentType**: The type identifier used to create the attachment filename

These values are stored in the process instance with the following structure:

```
generatedDocuments.generatedFiles.{{customId}}.{{templateName}}.minioPath
generatedDocuments.generatedFiles.{{customId}}.{{templateName}}.documentType
```

For example, if your document generation used:

* customId: "ClientsFolder"
* templateName: "AccountCreation"

The paths would be:

```json theme={"dark"}
...
  "attachments": [
    {
      "path": "${generatedDocuments.generatedFiles.ClientsFolder.AccountCreation.minioPath}",
      "filename": "${generatedDocuments.generatedFiles.ClientsFolder.AccountCreation.documentType}.pdf"
    }
  ]
```

> [!TIP]
>
> You can verify these values in the process instance details:
>
> ![Process instance details showing document paths](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/generate_doc_template_first.png)

### Step-by-step implementation

**1. Prepare your email template (notification template)**

Configure the template you'll use for the email:

* Define subject line, body text, and placeholders for dynamic content
* Set proper HTML formatting if needed
* Test the template to ensure it displays correctly

![Email template example](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/email_template.png)

See [Managing notification templates](https://docs.flowx.ai/6.x/docs/platform-deep-dive/core-extensions/content-management/notifications-plugin/managing-notification-templates.md) for detailed instructions.

**2. Verify Kafka topic configuration**

Confirm that the required Kafka topics are properly defined:

1. Navigate to **FlowX Designer → Platform Status**
2. Select **notification-plugin-mngt**
3. Expand **kafkaTopicsHealthCheckIndicator → details → configuration → topic → notification → internal**
4. Verify that the input and output topics for email notifications are listed

![](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/notif_kafka_topics.png)

**3. Add a Send Message Task (Kafka) and Receive Message Task (Kafka)**

In your process definition:

1. Open the process definition in your project in FlowX Designer
2. Add a [Send Message Task (Kafka)](https://docs.flowx.ai/6.x/docs/building-blocks/node/message-send-received-task-node.md#send-message-task) after the document generation step
3. Add a [Receive Message Task (Kafka)](https://docs.flowx.ai/6.x/docs/building-blocks/node/message-send-received-task-node.md#receive-message-task) after the Send Message Task

![](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/send_an_email_bpmn.png)

**4. Configure the email request payload (Send Message Task)**

On the Send Message Task, add a Kafka send action, add the corresponding Kafka topic and create the JSON payload containing all information needed for the email:

```json theme={"dark"}
{
  "templateName": "accountDetails",
  "receivers": ["something@email.com"],
  "language": "en",
  "data": {
    "firstInput": "${application.client.firstName}",
    "secondInput": "${application.client.lastName}"
  },
  "attachments": [
    {
      "path": "${generatedDocuments.generatedFiles.ClientsFolder.AccountCreation.minioPath}",
      "filename": "${generatedDocuments.generatedFiles.ClientsFolder.AccountCreation.documentType}.pdf"
    }
  ]
}
```

![](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/send_email_node.png)

Key parameters:

* **templateName**: The name of your configured email template
* **language**: The language code matching your template's language version
* **receivers**: Array of email addresses (can use process data variables)
* **ccReceivers**: Array of email addresses to be added as CC (can use process data variables)
* **bccReceivers**: Array of email addresses to be added as BCC (can use process data variables)
* **data**: Values to replace template placeholders (the older `contentParams` key is still accepted but deprecated)
* **attachments**: Array of files to attach, with filename and minioPath/storage path

**5. Configure the email success handler (Receive Message Task)**

On the Receive Message Task, add a Kafka receive action, add the corresponding Kafka topic and configure the node with the following properties:

* Go to **Node config** tab
* Under **Integration Output**, add a data stream (**Add Stream**) and set its **Source** to **Custom Topic**
* Add the topic name
* Click **Save**

![Kafka receive action configuration](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/Screenshot%202025-05-15%20at%2017.56.57.png)

**6. Run the process**

Run the process and check the result in the process instance details:

![Process instance details showing email success](https://s3.eu-west-1.amazonaws.com/docx.flowx.ai/470/result_send_email.png)

## Request payload reference

### Required fields

| Field | Description | Example |
| - | - | - |
| templateName | The unique identifier of your email template | "accountDetails" |
| language | Language code (must match a template language) | "en" |
| receivers | List of email addresses to receive the message | \["[customer@example.com](mailto:customer@example.com)"] |

### Optional fields

| Field | Description | Example |
| - | - | - |
| data | Key-value pairs for template variable replacement (the older `contentParams` key is still accepted but deprecated) | `{"firstName": "John"}` |
| attachments | List of files to attach to the email | See below |

### Attachment structure

Each attachment requires:

```json theme={"dark"}
{
  "path": "${path.to.file.in.storage}",
  "filename": "desired_filename.extension"
}
```

* **path**: References the storage location (usually a MinIO path from document generation)
* **filename**: The name recipients will see for the attached file (can include process variables)

## Testing and troubleshooting

After configuring your email notification:

1. Verify that variables resolve correctly in the template and attachment references
2. Check email delivery to test recipients
3. Review notification plugin logs if issues occur

### Common issues

| Problem | Solution |
| - | - |
| Email not received | Verify template name, receiver address, and SMTP configuration |
| Missing attachment | Check that the MinIO path is correct and the file exists |
| Template errors | Ensure all variables in template have corresponding values in `data` |
| Variable resolution | Confirm process variables use the correct path (check in process instance view) |

For further assistance, check the notification plugin logs in your environment.


## Related topics

- [Email Sender](https://docs.flowx.ai/6.x/docs/platform-deep-dive/integrations/email-sender.md)
- [Email Trigger](https://docs.flowx.ai/6.x/docs/platform-deep-dive/integrations/email-trigger.md)
- [Email Gateway setup](https://docs.flowx.ai/6.x/setup-guides/email-gateway-setup.md)
- [Send notification action](https://docs.flowx.ai/6.x/docs/building-blocks/actions/send-notification-action.md)
- [Microsoft Outlook](https://docs.flowx.ai/6.x/docs/platform-deep-dive/integrations/microsoft-outlook-data-source.md)


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