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

Speaker Featuring - Round 1

Speaker Featuring - Round 1

Every conference is more than the talks we see on stage it’s also the story of the people who make it possible.

With the first round of Into the Box 2026 sessions and workshops now live, we’re excited to introduce some of the speakers who will be joining us this year. These community members, practitioners, and Ortus team experts bring decades of real-world experience across CFML, BoxLang, JVM modernization, testing, AI, and cloud-native development.

Victor Campos
Victor Campos
January 26, 2026
First Round of the Into the Box 2026 Agenda Is Live

First Round of the Into the Box 2026 Agenda Is Live

Into the Box 2026 marks an important moment for the CFML and BoxLang community not just because of what’s on the agenda, but because of what it represents: 20 years of Ortus Solutions helping teams move forward, modernize, and build with confidence.

Victor Campos
Victor Campos
January 21, 2026
BoxLang AI v2: Enterprise AI Development Without the Complexity

BoxLang AI v2: Enterprise AI Development Without the Complexity

One Year. 100+ Features. Unlimited Possibilities.

Just one year ago, in March 2024, we launched BoxLang AI 1.0. Today, we're thrilled to announce BoxLang AI v2—a massive leap forward that positions BoxLang as the most powerful and versatile AI framework on the JVM.

Luis Majano
Luis Majano
January 19, 2026