开发者

Drupal get site wide email address?

开发者 https://www.devze.com 2023-01-11 07:00 出处:网络
In my module I want to get the site wide email address - the one开发者_Go百科 that is set in the site information admin pages and that is used for all automatically send email messages.

In my module I want to get the site wide email address - the one开发者_Go百科 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', '');


In Drupal 8:

$site_mail = \Drupal::config('system.site')->get('mail');


Looking into the system module, I found the settings form references the following:

variable_get('site_mail', ini_get('sendmail_from'));


You can get more ideas with this link

variable_get('site_mail', ini_get('sendmail_from'));


You can preprocess the variable like -

function hook_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.

0

精彩评论

暂无评论...
验证码 换一张
取 消