Skip to content

Commit 16a2fa6

Browse files
committed
add postfix version check, smtpd_relay_restrictions and stress adaptive behavior
add postfix version check add stress adaptive behavior (syntax changes with postfix version 3.0) add smtpd_relay_restrictions (postfix version 2.10)
1 parent 001d9fc commit 16a2fa6

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

install/lib/installer_base.lib.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,11 @@ public function configure_postfix($options = '') {
967967
$this->error("The postfix configuration directory '$config_dir' does not exist.");
968968
}
969969

970+
//* Get postfix version
971+
exec('postfix -d mail_version 2>&1', $out);
972+
$postfix_version = preg_replace('/.*=\s*/', '', $out[0]);
973+
unset($out);
974+
970975
//* mysql-virtual_domains.cf
971976
$this->process_postfix_config('mysql-virtual_domains.cf');
972977

@@ -1093,6 +1098,26 @@ public function configure_postfix($options = '') {
10931098
$postconf_tpl = strtr($postconf_tpl, $postconf_placeholders);
10941099
$postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines
10951100

1101+
//* Merge version-specific postfix config
1102+
if(version_compare($postfix_version , '2.5', '>=')) {
1103+
$configfile = 'postfix_2-5.conf';
1104+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master');
1105+
$content = strtr($content, $postconf_placeholders);
1106+
$postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content)));
1107+
}
1108+
if(version_compare($postfix_version , '2.10', '>=')) {
1109+
$configfile = 'postfix_2-10.conf';
1110+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master');
1111+
$content = strtr($content, $postconf_placeholders);
1112+
$postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content)));
1113+
}
1114+
if(version_compare($postfix_version , '3.0', '>=')) {
1115+
$configfile = 'postfix_3-0.conf';
1116+
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master');
1117+
$content = strtr($content, $postconf_placeholders);
1118+
$postconf_commands = array_merge($postconf_commands, array_filter(explode("\n", $content)));
1119+
}
1120+
10961121
//* These postconf commands will be executed on installation only
10971122
if($this->is_update == false) {
10981123
$postconf_commands = array_merge($postconf_commands, array(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Postfix configuration for version 2.10 and up
2+
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
3+
4+
# This is supported in version 2.9, but lets not create another conf file for it
5+
address_verify_sender_ttl = 15686s
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Postfix configuration for version 2.5 and up
2+
in_flow_delay = ${stress?3}${stress:1}s
3+
smtp_connect_timeout = ${stress?10}${stress:30}s
4+
smtp_helo_timeout = ${stress?10}${stress:60}s
5+
smtp_mail_timeout = ${stress?10}${stress:60}s
6+
smtpd_error_sleep_time = ${stress?1}${stress:2}s
7+
smtpd_hard_error_limit = ${stress?1}${stress:10}
8+
smtpd_recipient_overshoot_limit = ${stress?60}${stress:600}
9+
smtpd_soft_error_limit = ${stress?2}${stress:5}
10+
smtpd_timeout = ${stress?10}${stress:60}s
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Postfix configuration for version 3.0 and up
2+
in_flow_delay = ${stress?{3}:{1}}s
3+
smtp_connect_timeout = ${stress?{10}:{30}}s
4+
smtp_helo_timeout = ${stress?{10}:{60}}s
5+
smtp_mail_timeout = ${stress?{10}:{60}}s
6+
smtpd_error_sleep_time = ${stress?{1}:{2}}s
7+
smtpd_hard_error_limit = ${stress?{1}:{10}}
8+
smtpd_recipient_overshoot_limit = ${stress?{60}:{600}}
9+
smtpd_soft_error_limit = ${stress?{2}:{5}}
10+
smtpd_timeout = ${stress?{10}:{60}}s
11+

0 commit comments

Comments
 (0)