# Trigger · mail

Canonical URL: https://developers.iagenify.com/sdk/workflows/triggers/mail/
Language: en

`trigger: { type: "mail" }`

A message arriving at one of the account's own mailboxes starts a run, with the message as the input.

Status: an arriving message · the body is untrusted · needs a mailbox

```javascript
trigger: { type: "mail" }

{ id: "triage", type: "model.generate", config: {
    model: "gemini-3.5-flash",
    prompt: "Classify this message. Subject: {{input.subject}}\n\n{{input.text}}" } }
```

## It needs a mailbox {#needs}

The account must own one — see [api.mail](/sdk/ref/mail). Without it there is nothing for a message to arrive at.

## A message is the most untrusted input there is {#untrusted}

> **Anyone can send one**
>
> Its content reaches a model's prompt. Say what the step should do with it, and never let the body decide the task — a message asking to be forwarded somewhere is a message, not an instruction.

The agent's own mail tool carries the same rule in its description, for the same reason.

## Answering needs an approval {#approval}

A chain that replies ends in `mail.send`, which requires a `human` step upstream. An automatic answer to an arriving message is exactly the thing that must not happen unsupervised.

## The usual shape {#pattern}

- Classify the message with a model.
- Branch on the classification with a `condition` or a `switch`.
- File it with `storage.write` — no approval needed, it stays inside the account.
- For anything that answers: a `human` step, then `mail.send`.

- [mail.send](/sdk/workflows/steps/mail-send): Answering.
- [api.mail](/sdk/ref/mail): The mailboxes.

```python
trigger = {"type": "mail"}

{"id": "triage", "type": "model.generate", "config": {
    "model": "gemini-3.5-flash",
    "prompt": "Classify this message. Subject: {{input.subject}}\n\n{{input.text}}"}}
```
