From a template or a plugin, how can I get the value of admin/Settings/System Email Address ? Thanks for your help Nicolas
3 Answers
You can get this in a template like so:
{# returns an array of your email settings #}
{% set settings = craft.systemSettings.email %}
{# returns the email address #}
{{ settings.emailAddress }}
And in a plugin you can do:
craft()->systemSettings->getSetting('email', 'emailAddress')
In craft 3 it appears you can access it by doing the following:
{{ craft.systemSettings.email.fromEmail }}
The craft.systemSettings
variable was been deprecated as of Craft 3.1.0. Here's how to do it in Craft 3.1.0+:
{{ craft.app.projectConfig.get('email').fromEmail }}
Other email settings such as replyToEmail
and fromName
are also available via craft.app.projectConfig.get('email')
.
Alternatively, email settings can be accessed via the App
helper class:
{% set appHelper = create('craft\\helpers\\App') %}
{{ appHelper.mailSettings.fromEmail }}
Or in PHP:
$fromEmail = App::mailSettings()->fromEmail;