Blog

Victor Campos

October 14, 2025

Spread the word


Share your thoughts

Email Configuration with cbMailServices

Introduction

Have you ever accidentally brought your internal email servers down? Or worse, been banned for sending too many emails? Believe me, I’ve been there – and I’ve learned my lesson the hard way. Whether it’s a small typo or sending out thousands of unwanted emails, handling email systems can be tricky.

Luckily, ColdBox has you covered! With the cbMailServices module, you can streamline your email-sending process with ease. Forget about the complexities of the cfmail tag and script; with cbMailServices, you can send mail through various protocols, from email to SMS and even web sockets. Today, we'll dive into configuring this module for seamless email management.


1. Setting Up cbMailServices

ColdBox makes email configuration simple. To begin, you need to configure your ColdBox.cfc file, where you determine the mail settings, including the protocol you want to use. Here’s how to get started:


Example Configuration in ColdBox.cfc:

// config/ColdBox.cfc
mailsettings = {
    // Default token marker for mail body replacements
    tokenMarker = "@",

    // Sending protocol to use
    protocol = {
        class = "cbmailservices.models.protocols.CFMailProtocol",
        properties = {}
    }
};

2. Configuring Different Environments

cbMailServices allows you to easily adjust email behavior based on the environment your application is running in. For example, in production, you’ll likely want to send actual emails. But in development, you may prefer to log emails to a file to avoid flooding inboxes during testing.

Here’s how you can set up environment-specific mail configurations.

Example Environment-Specific Configuration:

// config/ColdBox.cfc
function configure() {
    mailsettings = {
        // CFMail Default Settings
        to      : "info@ortussolutions.com",
        from    : "myapp@sass.io",
        type    : "HTML",
        // Send Protocol
        protocol: {
            class: "cbmailservices.models.protocols.CFMailProtocol"
        }
    };
}

// Development mode: write emails to a log file
function development() {
    mailsettings.protocol = {
        class: "cbmailservices.models.protocols.FileProtocol",
        properties : { filePath : "/logs" }
    };
}

With this setup, emails in the development environment won’t be sent but logged, saving you from accidental email blasts!

3. Customizing Mail Properties

You can go beyond basic configuration and add custom properties. Any extra key you add to the mailsettings struct (that is not part of the standard configuration like tokenMarker or protocol) will be matched directly to the cfmail tag attributes.

For instance, you could add settings like fromto, and type to specify defaults for your emails.

Next Steps

Now that you’ve set up the configuration, you’re ready to send emails efficiently in ColdBox. In the next post, we’ll dive into how to send emails using cbMailServices—including using tokens, building mail bodies, and logging emails in different environments. Stay tuned!

Conclusion

Configuring email systems in ColdBox has never been easier. Whether you're using the default CFMail protocol or customizing your own, the cbMailServices module provides the flexibility and control you need to handle emails efficiently across different environments.


Learn More ColdBox Tips and Tricks

Stay tuned for more ColdBox tips in our ongoing series. if you want to learn more than 10 free tips and tricks make sure to get your “ColdBox 102 tips and tricks book” We have a variety of formats you can choose from.

Get your Copy

Join the Ortus Community

Be part of the movement shaping the future of web development. Stay connected and receive the latest updates on, product launches, tool updates, promo services and much more.

Subscribe to our newsletter for exclusive content.

Follow Us on Social media and don’t miss any news and updates:

Add Your Comment

Recent Entries

🚀 ColdBox CLI 8.11: The Era of AI Skills Comes to Every ColdBox & BoxLang App

🚀 ColdBox CLI 8.11: The Era of AI Skills Comes to Every ColdBox & BoxLang App

ColdBox CLI 8.11 is here, and it's one of the most significant releases we've shipped for AI-assisted development. This release wires the CLI directly into our brand new public skills directory at skills.boxlang.io, brings our AI tooling in line with industry-wide agent conventions, and introduces a wave of quality-of-life improvements that make AI integration feel less like setup and more like infrastructure.

Luis Majano
Luis Majano
April 30, 2026
🛰️ Introducing cbMCP — Your ColdBox App, Live to Every AI Agent

🛰️ Introducing cbMCP — Your ColdBox App, Live to Every AI Agent

Today we're releasing cbMCP, the official ColdBox MCP Server — a BoxLang-only module that turns your running ColdBox application into a fully-compliant Model Context Protocol (MCP) server. Plug in any MCP-capable AI client — Claude Desktop, VS Code Copilot, Cursor, Codex, Gemini CLI, OpenCode — and your AI assistant gets live, read-only introspection across the entire ColdBox platform: routing, handlers, modules, WireBox, CacheBox, LogBox, schedulers, interceptors, and async executors. 🎯

Luis Majano
Luis Majano
April 30, 2026