Cms: Manage email settings from the config file

Created on 31 Jan 2017  Â·  13Comments  Â·  Source: craftcms/cms

Created by: Hamish Taplin ([email protected]) on 2015/03/11 12:03:00 +0000
Votes at time of UserVoice import: 45


Currently, it's not possible to defined environment-specific email settings. This makes things difficult if you want to test emails with a service such as MailTrap.

Being able to define email settings in your config would makes things much more flexible.

All 13 comments

> Posted by Anonymous ([email protected]) on 2017/01/20 09:29:33 +0000

+1

> Posted by Boots ([email protected]) on 2016/09/08 20:22:30 +0000

+1 Config, config, config!

> Posted by 3 Red Kites ([email protected]) on 2015/05/16 15:59:27 +0000

+1

> Posted by Christopher Robert Kennedy ([email protected]) on 2015/03/20 22:52:33 +0000

Please, please, please. My clients don’t want us running test emails through their system, but changing settings between staging and production after pushing either way is irritating at best.

> Posted by TJ Draper ([email protected]) on 2016/03/08 03:25:40 +0000

+1. Config file for all config whenever possible.

> Posted by Stephen McIver ([email protected]) on 2015/04/13 23:58:09 +0000

+1 for this. It almost seems like an oversight that there's not a config setting for this already. Hope one gets added soon. Nice to be able to have all settings that change on a per-site basis like this in a single config file.

> Posted by Steven Grant ([email protected]) on 2015/03/10 17:09:13 +0000

given so much else can be defined in config, this would be a great addition.

This is possible in Craft 3 via config/app.php: https://github.com/craftcms/docs/blob/master/en/configuration.md#mailer-component

@brandonkelly Is the documentation up to date? The referenced method is deprecated and I cannot get this to work.

@joshuabaker Just updated that example to use the new method, but the old one will still work. One caveat with customizing the Mailer component from config/app.php is that those changes won’t be used when you test email settings from Settings → Email. (I also just updated the docs with a tip about that.) Is that where you’re finding that it’s not working?

@brandonkelly Thanks for clarifying. I was indeed using the test function.

Is it hugely complex to get this working with the test email function? I think it’ll be confusing to be unable to see the final config on that page and be unable to test it.

In an ideal world, it’d be good to have settings from a config/mailer.php config file merge into the component. That’d be cleaner from a multi-environment perspective.

That’s not possible, unfortunately. Though you can “test” your settings by creating a new user account with an email address you have access to, and check if the activation email reaches you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

angrybrad picture angrybrad  Â·  3Comments

timkelty picture timkelty  Â·  3Comments

michel-o picture michel-o  Â·  3Comments

brandonkelly picture brandonkelly  Â·  3Comments

RitterKnightCreative picture RitterKnightCreative  Â·  3Comments