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.
box install cbmailservices📖 Full documentation: cbmailservices.ortusbooks.com
Quick Example
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:
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
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
Last updated
Was this helpful?