In my module I want to get the site wide email address - the one that is set in the site information admin pages and that is used for all automatically send email messages.
How can I do this?
In my module I want to get the site wide email address - the one that is set in the site information admin pages and that is used for all automatically send email messages.
How can I do this?
$site_email = variable_get('site_mail', '');
Looking into the system module, I found the settings form references the following:
variable_get('site_mail', ini_get('sendmail_from'));
In Drupal 8:
$site_mail = \Drupal::config('system.site')->get('mail');
You can get more ideas with this link
variable_get('site_mail', ini_get('sendmail_from'));
You can preprocess the variable like -
function moi_preprocess(&$variables, $hook) {
$variables['site_email'] = \Drupal::config('system.site')->get('mail');
//kint( $variables['site_email']);
}
then use $variables['site_email']
anywhere to get the system wide email.