> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/ecosystem/mail.md).

# Mail

Send email from ColdBox applications with cbmailservices — protocol-based, testable, and environment-aware.

ColdBox sends email through the **cbmailservices** module: an object-oriented mailer with pluggable protocols, so your code never changes between environments.

```bash
box install cbmailservices
```

📖 **Full documentation:** [cbmailservices.ortusbooks.com](https://cbmailservices.ortusbooks.com)

## Quick Example

```javascript
property name="mailService" inject="MailService@cbmailservices";

var mail = mailService.newMail(
    to      : user.getEmail(),
    from    : "no-reply@myapp.com",
    subject : "Welcome!"
)

mail.setBody( renderView( "emails/welcome", { user : user } ) )
mailService.send( mail )
```

## Protocols

Switch delivery per environment without touching application code:

| Protocol   | Use                                            |
| ---------- | ---------------------------------------------- |
| `CFMail`   | Traditional engine mail sending                |
| `File`     | Write emails to disk — perfect for development |
| `Postmark` | Via the `PostBox` protocol module              |
| `SendGrid` | Via the `send-grid-protocol` module            |

```javascript
// config/ColdBox.bx — development
mailservices : {
    protocol : "file",
    filePath : "/runtime/mail"
}
```

You can build your own protocol by extending the base protocol class — the interface is small and documented in the module book.

## When to Use It

* Transactional email (welcome, password reset, receipts)
* Rendering email bodies with ColdBox views and layouts
* Testing mail flows locally without an SMTP server

## See Also

* [Queues](/ecosystem/queues.md) — queue mail sending with `cbq` for non-blocking delivery
* [Views](/the-basics/layouts-and-views/views.md) — rendering email templates


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://coldbox.ortusbooks.com/ecosystem/mail.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
