Skip to content

Commit 0cc57b5

Browse files
committed
allow sendmail_path php directive to work
1 parent 23ac700 commit 0cc57b5

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

server/conf/php_fpm_pool.conf.master

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4444
php_admin_value[session.save_path] = <tmpl_var name='document_root'>/tmp
4545
</tmpl_if>
4646
php_admin_value[upload_tmp_dir] = <tmpl_var name='document_root'>/tmp
47+
<tmpl_if name='custom_sendmail_path' op='!=' value='y'>
4748
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f webmaster@<tmpl_var name='domain'>"
4849
</tmpl_if>
50+
</tmpl_if>
4951

5052
<tmpl_loop name="custom_php_ini_settings">
5153
<tmpl_var name='ini_setting'>

server/conf/vhost.conf.master

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@
252252
SetEnv TMP <tmpl_var name='document_root'>/tmp
253253
SetEnv TMPDIR <tmpl_var name='document_root'>/tmp
254254
SetEnv TEMP <tmpl_var name='document_root'>/tmp
255+
<tmpl_if name='custom_sendmail_path' op='!=' value='y'>
255256
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>"
257+
</tmpl_if>
256258
php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
257259
php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
258260
# PHPIniDir <tmpl_var name='custom_php_ini_dir'>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ function update($event_name, $data) {
11761176
//* Create custom php.ini
11771177
if(trim($data['new']['custom_php_ini']) != '') {
11781178
$has_custom_php_ini = true;
1179+
$custom_sendmail_path = false;
11791180
if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir);
11801181

11811182
$php_ini_content = $this->get_master_php_ini_content($data['new']);
@@ -1200,6 +1201,13 @@ function update($event_name, $data) {
12001201
}
12011202
}
12021203

1204+
$custom_sendmail_path = false;
1205+
$line = strtok($php_ini_content, '\n');
1206+
while ($line !== false) {
1207+
if (strpos($line, 'sendmail_path') === 0) $custom_sendmail_path = true;
1208+
$line = strtok('\n');
1209+
}
1210+
12031211
$app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content);
12041212
} else {
12051213
$has_custom_php_ini = false;
@@ -1244,7 +1252,7 @@ function update($event_name, $data) {
12441252
$trans = array(
12451253
'{DOCROOT}' => $vhost_data['web_document_root_www'],
12461254
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root'],
1247-
'{DOMAIN}' => $vhost_data['domain']
1255+
'{DOMAIN}' => $vhost_data['domain']
12481256
);
12491257
$vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans);
12501258

@@ -1309,6 +1317,8 @@ function update($event_name, $data) {
13091317
$vhost_data['seo_redirect_enabled'] = 0;
13101318
}
13111319

1320+
$vhost_data['custom_sendmail_path'] = (isset($custom_sendmail_path) && $custom_sendmail_path) ? 'y' : 'n';
1321+
13121322
$tpl->setVar($vhost_data);
13131323
$tpl->setVar('apache_version', $app->system->getapacheversion());
13141324

@@ -3366,6 +3376,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
33663376
}
33673377

33683378
$custom_session_save_path = false;
3379+
$custom_sendmail_path = false;
33693380
if($custom_php_ini_settings != ''){
33703381
// Make sure we only have Unix linebreaks
33713382
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
@@ -3383,6 +3394,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
33833394
if($value != ''){
33843395
$key = trim($key);
33853396
if($key == 'session.save_path') $custom_session_save_path = true;
3397+
if($key == 'sendmail_path') $custom_sendmail_path = true;
33863398
switch (strtolower($value)) {
33873399
case '0':
33883400
// PHP-FPM might complain about invalid boolean value if you use 0
@@ -3405,6 +3417,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
34053417
}
34063418

34073419
$tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n'));
3420+
$tpl->setVar('custom_sendmail_path', ($custom_sendmail_path ? 'y' : 'n'));
34083421

34093422
$tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
34103423

server/plugins-available/nginx_plugin.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
29542954
}
29552955

29562956
$custom_session_save_path = false;
2957+
$custom_sendmail_path = false;
29572958
if($custom_php_ini_settings != ''){
29582959
// Make sure we only have Unix linebreaks
29592960
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
@@ -2971,6 +2972,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
29712972
if($value != ''){
29722973
$key = trim($key);
29732974
if($key == 'session.save_path') $custom_session_save_path = true;
2975+
if($key == 'sendmail_path') $custom_sendmail_path = true;
29742976
switch (strtolower($value)) {
29752977
case '0':
29762978
// PHP-FPM might complain about invalid boolean value if you use 0
@@ -2993,6 +2995,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
29932995
}
29942996

29952997
$tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n'));
2998+
$tpl->setVar('custom_sendmail_path', ($custom_sendmail_path ? 'y' : 'n'));
29962999

29973000
$tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
29983001

0 commit comments

Comments
 (0)