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

12 Days of BoxLang - Day 4: TestBox

12 Days of BoxLang - Day 4: TestBox

Today we’re celebrating one of the most exciting new additions to the BoxLang ecosystem:

the TestBox BoxLang CLI Runner — a fast, native way to run your TestBox tests directly through the BoxLang Runtime. ⚡

No server required. No CommandBox needed. Just pure, ultra-fast BoxLang-powered testing from the command lineon Windows, Mac, and Linux.

If you’re building modern applications with BoxLang — web apps, CLIs, serverless functions, Android apps, or OS-level utilities — this new feature gives you a unified, flexible testing workflow you can run anywhere.

Victor Campos
Victor Campos
December 13, 2025
12 days of BoxLang - Day 3: SocketBox!

12 days of BoxLang - Day 3: SocketBox!

As BoxLang continues evolving into a modern, high-performance, JVM-based runtime, real-time communication becomes essential for the applications we all want to build: dashboards, collaboration tools, notifications, live feeds, multiplayer features, and more.

That’s where SocketBox steps in — the WebSocket upgrade listener built to work seamlessly with CommandBox and the BoxLang MiniServer. ⚡

Today, for Day 3, we’re highlighting how SocketBox supercharges BoxLang development by giving you fast, flexible, and framework-agnostic WebSocket capabilities.

Maria Jose Herrera
Maria Jose Herrera
December 12, 2025
12 Days of BoxLang - Day 2: CommandBox

12 Days of BoxLang - Day 2: CommandBox

BoxLang + CommandBox: The Enterprise Engine Behind Your Deployments

For Day 2 of our 12 Days of Christmas series, we’re diving into one of the most powerful parts of the BoxLang ecosystem: CommandBox the defacto enterprise servlet deployment platform for BoxLang.

If BoxLang is the language powering your applications, CommandBox is the engine room behind it all. ⚙️

Victor Campos
Victor Campos
December 11, 2025