Drupal get site wide email address?

2019-04-03 05:17发布

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?

标签: email drupal
5条回答
Melony?
2楼-- · 2019-04-03 05:41

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.

查看更多
戒情不戒烟
3楼-- · 2019-04-03 05:43

In Drupal 8:

$site_mail = \Drupal::config('system.site')->get('mail');
查看更多
Fickle 薄情
4楼-- · 2019-04-03 05:44
$site_email = variable_get('site_mail', '');
查看更多
我命由我不由天
5楼-- · 2019-04-03 05:46

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

variable_get('site_mail', ini_get('sendmail_from'));
查看更多
孤傲高冷的网名
6楼-- · 2019-04-03 05:57

You can get more ideas with this link

variable_get('site_mail', ini_get('sendmail_from'));
查看更多
登录 后发表回答