# An email arrives

> Starts when an email arrives with a document attached.

Source: https://docs.go-lumen.ai/reference/triggers/email-arrives

## At a glance

| Property | Value |
| --- | --- |
| **Trigger name** | `email-arrives` |
| **Resource** | ClusterTrigger (`lumen.ai/v1alpha1`) |
| **Source** | event |
| **Needs a connection** | yes, one that provides `email` |
| **Produces** | `email`, `file` |
| **Emits** | item |
| **Installation must provide** | nothing |

A flow using this trigger names a Connector in `connectorRef`. Connection types that provide `email`: \[Email forwarding\](/reference/connections/email-forward).

The trigger goes under `spec.triggers` of a Flow. Its outputs are referenced as `<triggerId>.<field>`. A trigger can also carry a `when` condition ("Start only when") and `disabled: true`.

## Outputs

A later node references an output as `{nodeId.field}` in text, or `nodeId.field` in a condition.

| Output | Type |
| --- | --- |
| `from` | string |
| `to` | string |
| `subject` | string |
| `body` | string |
| `attachments` | number |
| `senderVerified` | boolean |
| `receivedAt` | date |
| `messageId` | string |

## Settings

Set under `config:` on the flow trigger.

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `requireAttachment` | boolean | `true` | RequireAttachment drops mail that carries no file; unset is true. |
| `maxSizeMB` | integer | `25` | MaxSizeMB starts no run for a mail bigger than this; unset is 25. (minimum 1; maximum 40) |
| `attachments` | string |  | Each attachment separately: every file goes through the flow on its own, with the email's sender, subject and body, so reply and forward steps answer once per file. The whole email as one: all the files travel together as one document. A trigger saved before this setting existed works as the whole email as one. (one of separate, together) |
| `includeInline` | boolean | `false` | Include images in the email body |

The full JSON Schema of these settings: [email-arrives.schema.json](https://docs.go-lumen.ai/schemas/triggers/email-arrives.schema.json).

## Use it in a flow

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: my-email-forward
  namespace: tenant-acme
spec:
  classRef: {name: email-forward}
  config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: email-arrives-example
  namespace: tenant-acme
spec:
  displayName: "An email arrives"
  triggers:
    - id: start
      ref: {name: email-arrives}
      connectorRef: {name: my-email-forward}
      next: [notify-in-app]
  nodes:
    - id: notify-in-app
      stepRef: {name: notify-in-app}
      config:
        body: 'Total: {total}'
        title: New invoice from {supplier}
        to: admins
```
