Bamboo is an Elixir email library that separates composing messages from delivery, with adapters for common transactional providers.
Overview
Bamboo is an Elixir package for building and sending email using plain functions and pipelines. It is maintained by the BEAM Community and was originally created by thoughtbot. You define email modules to construct messages and mailer modules that handle delivery through a configured adapter.
Built-in adapters cover Mandrill, Mailgun, and SendGrid, with community adapters for other services and a straightforward path to custom adapters by implementing the Bamboo.Adapter behaviour. Local and test adapters store messages in memory or capture them in-process for development and automated tests. A development plug can expose sent messages in the browser during local work.
Delivery can be synchronous or deferred with deliver_later, which by default uses a task supervisor strategy so sending does not block the caller or crash the app on mailer errors. Custom deliver-later strategies can integrate with background queues. Bamboo supports Phoenix views and layouts for HTML email, JSON encoding via Jason, interceptors to modify or block messages per mailer, and the Bamboo.Formatter protocol for recipient structs.
The library emphasizes testability by letting you assert on email structs without special test APIs, and it provides helpers for integration tests when using the test adapter.
Key features
- Separate email and mailer modules
- Mandrill, Mailgun, SendGrid adapters
- Background deliver_later sending
- Local and test in-memory adapters
- Phoenix view and layout rendering
- Development sent-email viewer plug
- Per-mailer interceptors
- Formatter protocol for recipients
Use cases
- Sending mail from Elixir and Phoenix apps
- Unit testing email content without delivery
- Integrating transactional email providers
- Previewing messages during development
- Queueing outbound email in the background