# Email forwarding

> Give your workspace an email address, forward the mail you choose to it, and start flows from what arrives. Covers allowed senders, attachments, size limits and what happens to duplicates.

Source: https://docs.go-lumen.ai/he/connectors/email-forwarding

An email forwarding connection is an address that belongs to your workspace. You forward the mail you want handled to it, and every message that arrives can start a flow. Nothing in your own mailbox is read, moved or deleted.

-   5 minutes
-   No credentials
-   Admin to create

Use forwarding when you can add a rule in your mail client or on your mail server. If you cannot (for example, you may not change mail rules, or you want Lumen to read a mailbox that already exists), connect the mailbox instead: see [Gmail and mailboxes](https://docs.go-lumen.ai/he/connectors/gmail-and-mailboxes.md).

## Create the address

You need to be a workspace admin. The address is made for you; you do not pick it.

**Console:**

1.  In the sidebar, open **Connectors**. The page is titled **Connections**.
2.  Click **Add connection** and choose **Email forwarding**.
3.  Optionally give it a **Name**, such as `Supplier invoices`. Without one, the connection is named by its address.
4.  Under **Allowed senders**, type an address (`dana@acme.example`) or a whole domain (`*@supplier.example`) and press Enter. Repeat for each one. Leave it empty to accept mail from anyone.
5.  Click **Add Email forwarding**. The new connection opens with **Forward your mail to this address**, and a **Copy address** button.

![The Add connection panel for Email forwarding. Name holds Invoices. Allowed senders holds two entries, Anyone at supplier.example and dana@acme.example, with the note that only these senders can start flows and that each must also pass the SPF or DKIM check, so a forged From is refused.](https://docs.go-lumen.ai/he/img/connectors/email-forwarding-01-add-address.png)

*Email forwarding has no credentials. The allowed senders are the only setting.*

**YAML:**

```yaml title="forwarding-suppliers.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: forwarding-suppliers
  namespace: tenant-acme
spec:
  classRef: {name: email-forward}
  config:
    allowedSenders: ["*@supplier.example", dana@acme.example]
```

Lumen writes the address into `config.address` when the connection is created, and it never changes after that. Read it back with `lumen get connectors forwarding-suppliers -o yaml`.

> **The address cannot be edited:**
> 
> Delete the connection and create it again and you get a different address, and everyone who forwards to the old one has to change. Mail sent to a deleted address is accepted and thrown away, with no bounce, so nobody notices.

## Forward your mail to it

In your mail client or mail server, add a forwarding rule that sends a copy to the address. Narrow it with a filter so only the messages you want are sent: for example, mail from your suppliers, or mail with an attachment.

In Gmail, open **Settings**, then **Forwarding**, then **Add a forwarding address**, and use a filter to choose which messages go.

Check that it works: open the connection and click **Setup steps**, then send one message to the address. It appears under **Recent mail** within seconds, with an icon that says whether it was accepted or refused, and why.

Each arrival is kept as a row in that list, so you can see mail that did not start a flow:

| Outcome in **Recent mail** | Why |
| --- | --- |
| Accepted | The sender is allowed and the message was read. Whether a flow started is shown on the flow's trigger, under **Recent emails**. |
| Refused: the sender is not on the allowed list | The address has **Allowed senders** and this one is not on it. |
| Refused: the sender failed the SPF or DKIM check | The address has **Allowed senders** and the message could not be verified as coming from that sender. |
| Refused: this address is paused | The connection is paused. |
| Refused: the message could not be read | The message was not valid mail. |

## Which senders are accepted

With no allowed senders, anyone who knows the address can start your flows. That is fine for an address only your own mail rules use, and risky for one that is public.

With allowed senders:

-   An entry is a full address or `*@domain`. Case is ignored.
-   The sender must also be verified. Lumen does not run SPF, DKIM or DMARC itself. It reads the verdict of the server that received the message, and counts the sender as verified when DMARC passed, or when the domain has no DMARC policy and SPF or DKIM passed for a domain that matches the From address. A message that fails is refused, so a forged From address cannot get through an allow list.
-   A sender who is not on the list gets a bounce from their mail server ("This recipient does not accept mail from this sender"). A sender who fails verification gets no bounce, because bouncing a forged message would mail the person it pretends to be.

Without allowed senders the mail is accepted whatever the verdict, and `senderVerified` is an output of the trigger that a flow can test. See [Triggers](https://docs.go-lumen.ai/he/build/triggers.md) for **Start only when**.

To change the list, open the connection, edit **Allowed senders** and click **Save**.

## Start a flow from it

Add the trigger **An email arrives**, keep **Source** at **A Lumen forwarding address**, and pick the address under **Which address starts this flow?**.

![The settings of the trigger An email arrives. Source is set to A Lumen forwarding address. Which address starts this flow shows a forwarding address ending in in.lumen.example, labeled Email forwarding. Attachments is set to Each attachment separately, with the other choice being The whole email as one.](https://docs.go-lumen.ai/he/img/connectors/email-forwarding-02-trigger.png)

*The trigger's settings. The address list holds every forwarding address in the workspace.*

| Setting | Default | What it does |
| --- | --- | --- |
| **Attachments** (`attachments`) | **Each attachment separately** for a new trigger | **Each attachment separately** makes one document per file, each carrying the sender, subject and body, so a reply or forward step answers once per file. **The whole email as one** keeps every file in one document. |
| **Largest mail (MB)** (`maxSizeMB`) | 25 | A bigger message starts no run. You can set 1 to 40, but forwarding itself accepts at most 25 MB a message. |
| **Only emails with an attachment** (`requireAttachment`) | On | Turn it off to start a flow on every message. |
| **Start only when** (`when`) | None | A condition on the email's own fields, checked before anything is stored: a message that does not match starts no run and costs nothing. |

The trigger gives the flow these fields, as `{email.from}` if the trigger's id is `email`: `from`, `to`, `subject`, `body`, `attachments` (how many files it took), `senderVerified`, `receivedAt` and `messageId`.

```yaml title="forwarding-supplier-invoices.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: forwarding-supplier-invoices
  namespace: tenant-acme
spec:
  displayName: Keep supplier invoices
  triggers:
    - id: email
      ref: {name: email-arrives}
      connectorRef: {name: forwarding-suppliers}
      config: {attachments: separate, requireAttachment: true, maxSizeMB: 20}
      when: {field: email.subject, op: contains, value: invoice}
      next: [pdfs]
  nodes:
    - id: pdfs
      stepRef: {name: keep-pdfs}
      next: [keep]
    - id: keep
      stepRef: {name: save-file}
      config: {destination: lumen, folder: "Invoices/{date:yyyy-MM}"}
```

The flow starts for each PDF in a message from `supplier.example` or Dana whose subject contains `invoice`, and saves the file in a monthly folder in Files. The connection it uses is the one in the first block of this page.

## Attachments and limits

-   A run takes at most 20 files from one message. The rest are left out, and every document of the run carries `skippedAttachments` with how many.
-   Images shown in the body of the email, such as a logo, are not files. When a message has no document at all, photos attached to it count as its files, so a photographed receipt still starts a flow.
-   A message over **Largest mail (MB)** is recorded and starts no run.
-   A trigger saved before the **Attachments** setting existed behaves as **The whole email as one**, so older flows do not change.

## Duplicates

Lumen remembers the Message-ID of every message. If the same message reaches the address twice (a mail rule that fires twice, or a retry by the sending server), it starts one run per flow, not two. A message with no Message-ID is identified by a hash of its content.

Two different messages with the same subject and files are two arrivals. To skip a repeated invoice, use the **Skip duplicates** step on a key from the document, such as the supplier and invoice number.

## Pause or disconnect

**Pause** in the connection's panel stops it taking mail: senders get a bounce saying the address is not accepting mail, and **Resume** turns it back on. **Disconnect** is final, and is refused while flows still start from the address: pause it, or change those flows first.

## Next steps

[Gmail and mailboxesRead a mailbox you already have instead of forwarding mail out of it.](https://docs.go-lumen.ai/he/connectors/gmail-and-mailboxes.md)[TriggersEvery way to start a flow, and the Start only when condition.](https://docs.go-lumen.ai/he/build/triggers.md)[Send it to me by emailSend mail from a flow once the one you forwarded has been handled.](https://docs.go-lumen.ai/he/reference/steps/send-email.md)[One document or a batchHow separate attachments become separate documents in a run.](https://docs.go-lumen.ai/he/concepts/one-document-or-a-batch.md)
