Automatically configure your Craft CMS email settings based on your environment.
Craft 2.x doesn't allow email to be automatically configured on a per-environment basis. This plugin fixes that, and allows you to have different email settings depending on the environment your Craft site is running in. For example the local / development versions of your site could use one email provider, and the live version another.
It is recommended that you configure the plugin email settings before installing the plugin in the Control Panel.
This plugin works with Craft 2.4.x and Craft 2.5.x. It isn't required for Craft 3.
Download and unzip the plugin in your
craft/plugins folder. Make sure the plugin folder is called
Once that's done, view the Craft Control Panel, go to Settings > Plugins, then you should see the plugin has been detected by Craft. Before hitting Install, we should configure the email settings for each environment.
craft/plugins/emailsettings/config.php. You’ll see some example email configurations here:
return [ // Global settings '*' => [ 'emailAddress' => 'email@example.com', 'port' => '25', // Valid options are 'sendmail', 'smtp', 'pop' or 'gmail' 'protocol' => 'smtp', 'senderName' => 'Red Robot', 'smtpAuth' => 1, 'smtpKeepAlive' => 0, // Valid options are 'none', 'ssl' or 'tls' 'smtpSecureTransportType' => 'none', 'template' => '', 'timeout' => '30' ], // Mail trap settings 'mailtrap' => [ 'username' => 'username', 'password' => 'password', 'host' => 'smtp.mailtrap.io' ], // Live email site settings 'live' => [ 'username' => 'username', 'password' => 'password', 'host' => 'smtp.emailprovider.net' ] ];
You should edit / add a configuration array for each email provider you’ll be using.
Email settings in the plugin file are ‘merged / inherited’ in the same was as the Craft general config file.
Once you’ve configured the various email provider details, open
craft/config/general.php. To make all domains use the ‘mailtrap’ configuration (for example), edit the file as follows:
return [ '*' => [ 'siteUrl' => SITE_URL, // ... 'emailConfig' => 'mailtrap' ] ]
Now every environment will use the ‘mailtrap’ configuration defined in
craft/plugins/emailsettings/config.php. Add additional
emailConfig keys / values to configure email for your other environments as needed.
Once you’ve finished with the configuration, hit ‘Install’, then visit Settings > Email in the Craft Control Panel. You should see a notice saying the settings are being overridden by the plugin. Scroll down, hit ‘Test’, and you should receive a test email using the email provider for the current environment.
If you change any of the email settings in either the plugin config file, or the Craft plugin file, the site email configuration will updated the next time a page is viewed in the site (i.e. you can just refresh the Email Settings page, and the settings will be updated automatically).
Once your configuration files are updated, Craft will automatically switch email settings depending on the environment it's running in.
Sound good? Why not buy it now? A one off payment gives you license to use the plugin on as many sites as you like, with unlimited free updates. Click the button below, and we'll send you the download link once we've received your payment.