Using the Pixel & Tonic Contact Form plugin, I added a config file (config/contactform.php) to override plugin settings from the CP.

I would like to change some settings if devMode is enabled : recipients from the contact form plugin, to separate my tests addresses from my client addresses.


$recipients = array(
    'devMode' => 'example@domain.com,example@domain.com',
    'prodMode' => 'john@doe.com,jean@dupont.com'

if (devMode == true) {
    $recipients = $recipients['devMode'];
} else {
    $recipients = $recipients['prodMode'];

return array(
    'toEmail' => ($recipients ?: null),

How can I check if devMode == true? Can I access to this value using craft()->config or something else that?

2 Answers 2


It's as simple as

if ( craft()->config->get( 'devMode' ) )
 //do stuff
  • Using this, I get this error : The property « Craft\ConfigService.devMode » is undefined.. Yes, I'm using environment variables, but following the other answer there is no devMode data that I can get from the craft()->config->get('environmentVariables'), while devMode is enabled in my current dev environment. Jun 29, 2016 at 8:34
  • This is because you're not in the Craft namespace. Included in most files is a namespace Craft; declaration at the top of the file, but in config files this is not usually there. You could either add this namespace declaration to your config file, or use \Craft\craft()->config->devMode instead. Jun 29, 2016 at 8:37
  • namespace Craft; was already specified at the first line of my config/contactform.php file. Jun 29, 2016 at 8:39
  • Ok, I found the solution : craft()->config->get('devMode') does the job. Thank you ! Jun 29, 2016 at 8:41
  • 2
    Oh I see, I misread the original error. I'm pretty sure you need to use craft()->config->get('devMode') instead Jun 29, 2016 at 8:41

For those coming here using Craft 3, it's now Craft::$app->getConfig()->general->devMode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.