# mail.message.send

Sends one email through a stored smtp credential's relay

# mail.message.send

```
mail.message.send --credential TEXT --recipient TEXT… --subject TEXT [--text TEXT] [--html TEXT] [--sender TEXT] [--reply-to TEXT] [--file FILE…] [--inline KEY=FILE…] [--store VALUE] → message
```

Sends one email through a stored smtp credential's relay. It goes to every `--recipient` (repeat, up to 50), with `--subject` and `--text` and/or `--html`; `--file` attaches a stored file (repeat; it arrives under the FileRef's filename, or the key's last segment) and `--inline id=FILE` places a picture the HTML draws as `<img src="cid:id">`. Every value takes a literal or {{ expr }}. Adds `message: { sent, id, recipient, subject, attached }` and keeps the rest of the payload. Submission only — deliverability (SPF, DKIM, reputation) is the relay's job.

## Flags

- `--credential` (required): The smtp credential naming the relay.
- `--recipient` (required): An address to send to — repeat for several, or one {{ [list] }}.
- `--subject` (required): The subject line.
- `--text`: The plain-text body.
- `--html`: The HTML body. Given both, the mail is multipart/alternative.
- `--sender`: The From address, instead of the credential's.
- `--reply-to`: Where replies go, when that is not the sender.
- `--file`: A file to attach: a FileRef or a store key, repeated. It arrives under the FileRef's filename, or the key's last segment.
- `--inline`: A picture the HTML draws inline: id=FILE (FileRef or store key), placed with <img src="cid:id">. Repeat for several; sent as a plain attachment when there is no --html.
- `--store`: The project store to write to: `local`, or the id of an `s3` credential. Saved explicitly when the pipeline is registered (default: the project's default store at that moment)

## Examples

### Confirmation after a form

```
| mail.message.send --credential smtp_main --recipient "{{ $trigger.body.email }}" --subject "We got your message" --text "Thanks {{ $trigger.body.name }}, we will reply within a day."
```

Adds `message` to the payload and keeps the rest. The credential is created by the owner in Studio → Credentials (kind smtp).

It answers:

```json
{
  "message": {
    "sent": true,
    "id": "<1759.mb@mail.example.com>",
    "recipient": [
      "a@example.com"
    ],
    "subject": "We got your message",
    "attached": []
  }
}
```

### A certificate as an attachment

```
| mail.message.send --credential smtp_main --recipient "{{ input.query.rows[0].email }}" --subject "Your certificate" --text "Attached." --file "{{ input.document }}"
```
