﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
url: https://docs.puppetflow.com/guide/mailboxes.md
---
# Mailboxes

Mailboxes let you receive emails on custom domains and use them in your automations. This is how Puppetflow handles email verification flows, OTP codes sent by email, and any scenario where your automation needs to read incoming mail.

## How it works

1. Configure a [mailbox integration](/guide/integrations#mailbox-integration) with a verified domain.
2. Create a mailbox (e.g. `verify@yourdomain.com`).
3. Set up a **watcher** on a flow to listen for matching emails.
4. In your flow code, call `$waitForEmail('watcher-id')` to pause until a matching email arrives.

## Creating a mailbox

Go to **Mailboxes** and click **New Mailbox**:

| Field | Description |
| --- | --- |
| **Mailbox address** | Local part and verified domain. |
| **Description (Optional)** | Optional note. |
| **Group** | Optional organizational group. |
| **Visibility** | Owner, Team, or Workspace. |
| **Owner** | Workspace member who owns the mailbox. |

The full address is `local-part@domain`.

## Browsing emails

The mailbox UI has three panels:

1. **Mailbox list** - All your mailboxes with unread badges.
2. **Email list** - Emails in the selected mailbox with search and sort.
3. **Email preview** - Full email content with HTML rendering.

You can mark emails as read/unread and delete them individually.

## Mailbox watchers

Watchers are attached to a flow and define rules for matching incoming emails. When a flow is running and calls `$waitForEmail('watcher-id')`, Puppetflow checks incoming emails against the watcher's rules.

### Creating a watcher

In the flow editor, go to the **Mailboxes** tab:

1. Select a mailbox to watch.
2. Give the watcher a name (used in your code).
3. Define matching rules.
4. Optionally enable additional parsing.

### Matching rules

Rules can inspect **Body**, **Subject**, **To**, **From**, **Has Attachments**, and **Size**.

Every field supports **Contains**, **Not Contains**, **Equals**, **Greater Than**, **Less Than**, and **Regex**.

Rules are grouped with AND/OR logic. All rules in a group must match (AND), and any group can match (OR).

### Additional parsing

Enable **Additional parsing** and choose **Regex** or **XPath Selector**. The extracted result is available as `parsed`, with `parsed_value` as an alias.

Example: extract a 6-digit verification code:

```
/code[:\s]*(\d{6})/i
```

### Using watchers in code

```js
const email = await $waitForEmail('watcher-id', {
  timeout: 300000 // milliseconds, default: watcher config or 300000
});

// email.parsed contains the extracted value (if regex enabled)
await $fillInput('#code', email.parsed);
```

The method blocks until a matching email arrives or the timeout expires.

## SMTP server

Puppetflow includes a built-in SMTP server that receives incoming emails. It r