# An email arrives in a mailbox

> Starts when a new email arrives in a mailbox you connect over IMAP, such as an Exchange or company mailbox.

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

## Auf einen Blick

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

A flow using this trigger names a Connector in `connectorRef`. Connection types that provide `mailbox`: \[Mailbox (IMAP)\](/reference/connections/imap-mailbox), \[Microsoft 365\](/reference/connections/microsoft-365).

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`.

## Ausgaben

Ein späterer Knoten verweist auf eine Ausgabe als `{nodeId.field}` in einem Text oder als `nodeId.field` in einer Bedingung.

| Ausgabe | Typ |
| --- | --- |
| `from` | string |
| `to` | string |
| `subject` | string |
| `body` | string |
| `attachments` | number |
| `senderVerified` | boolean |
| `receivedAt` | date |
| `messageId` | string |

## Einstellungen

Wird unter `config:` im Auslöser des Flows gesetzt.

| Einstellung | Typ | Standardwert | Beschreibung |
| --- | --- | --- | --- |
| `folder` | string | `"INBOX"` | Folder is the mailbox folder to watch; unset is INBOX. (maxLength 255) |
| `filters` | object |  | Filters keep only the mail that matches; leave them out to take everything. |
| `filters.fromContains` | string |  | Sender contains (maxLength 200) |
| `filters.subjectContains` | string |  | Subject contains (maxLength 200) |
| `afterHandling` | object |  | AfterHandling says what happens to a mail the flow took. |
| `afterHandling.mode` | string | `"markRead"` | Then (one of markRead, moveTo, leave) |
| `afterHandling.folder` | string |  | Folder is where moveTo puts the mail. (maxLength 255) |
| `pollMinutes` | integer | `5` | PollMinutes is how often the mailbox is looked at. (minimum 1; maximum 60) |
| `includeAttachments` | boolean | `true` | IncludeAttachments takes the mail's files along; unset is true. |
| `requireAttachment` | boolean | `false` | RequireAttachment drops mail that carries no file; unset is false, so a mailbox trigger saved before the setting takes every mail as it did. |
| `maxSizeMB` | integer | `25` | MaxSizeMB refuses a mail bigger than this; unset is 25. (minimum 1; maximum 40) |
| `importExisting` | integer | `0` | Takes the newest N mails in the folder, before the filters, once when the folder is first read. More than 50 are worked off over several checks. (minimum 0; maximum 500) |
| `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 |

Das vollständige JSON Schema dieser Einstellungen: [mailbox-email.schema.json](https://docs.go-lumen.ai/schemas/triggers/mailbox-email.schema.json).

## Im Flow verwenden

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: my-imap-mailbox
  namespace: tenant-acme
spec:
  classRef: {name: imap-mailbox}
  config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: mailbox-email-example
  namespace: tenant-acme
spec:
  displayName: "An email arrives in a mailbox"
  triggers:
    - id: start
      ref: {name: mailbox-email}
      connectorRef: {name: my-imap-mailbox}
      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
```
