Skip to content

Commit 1e9c388

Browse files
committed
postfix_server_plugin checks for dovecot lmtp and sieve (#3395 and #4792)
1 parent 1bce29f commit 1e9c388

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

server/plugins-available/postfix_server_plugin.inc.php

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,35 @@ function update($event_name, $data) {
158158
}
159159

160160
if($app->system->is_installed('dovecot')) {
161+
$virtual_transport = 'dovecot';
162+
$configure_lmtp = false;
163+
$dovecot_protocols = 'imap pop3';
164+
165+
//* dovecot-lmtpd
166+
if( ($configure_lmtp = is_file('/usr/lib/dovecot/lmtp')) ||
167+
($mail_config["mailbox_virtual_uidgid_maps"] == 'y') )
168+
{
169+
$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
170+
$dovecot_protocols .= ' lmtp';
171+
}
172+
173+
//* dovecot-managesieved
174+
if(is_file('/usr/lib/dovecot/managesieve')) {
175+
$dovecot_protocols .= ' sieve';
176+
}
177+
161178
$out = null;
162179
exec("postconf -n virtual_transport", $out);
163-
if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') {
164-
// If dovecot switch to lmtp
165-
if($out[0] != "virtual_transport = lmtp:unix:private/dovecot-lmtp") {
166-
exec("postconf -e 'virtual_transport = lmtp:unix:private/dovecot-lmtp'");
167-
exec('postfix reload');
168-
$app->system->replaceLine("/etc/dovecot/dovecot.conf", "protocols = imap pop3", "protocols = imap pop3 lmtp");
169-
exec($conf['init_scripts'] . '/' . 'dovecot restart');
170-
}
171-
} else {
172-
// If dovecot switch to dovecot
173-
if($out[0] != "virtual_transport = dovecot") {
174-
exec("postconf -e 'virtual_transport = dovecot'");
175-
exec('postfix reload');
176-
$app->system->replaceLine("/etc/dovecot/dovecot.conf", "protocols = imap pop3 lmtp", "protocols = imap pop3");
177-
exec($conf['init_scripts'] . '/' . 'dovecot restart');
178-
}
180+
if($out[0] != "virtual_transport = $virtual_transport") {
181+
exec("postconf -e 'virtual_transport = $virtual_transport'");
182+
exec('postfix reload');
183+
}
184+
185+
$out = null;
186+
exec("grep '^protocols\s' /etc/dovecot/dovecot.conf", $out);
187+
if($out[0] != "protocols = $dovecot_protocols") {
188+
$app->system->replaceLine("/etc/dovecot/dovecot.conf", 'REGEX:/^protocols\s=/', "protocols = $dovecot_protocols");
189+
exec($conf['init_scripts'] . '/' . 'dovecot restart');
179190
}
180191
}
181192

@@ -222,7 +233,7 @@ function update($event_name, $data) {
222233
exec("postconf -X 'milter_default_action'");
223234

224235
exec("postconf -e 'receive_override_options = no_address_mappings'");
225-
exec("postconf -e 'content_filter = amavis:[127.0.0.1]:10024'");
236+
exec("postconf -e 'content_filter = " . ($configure_lmtp ? "lmtp" : "amavis" ) . ":[127.0.0.1]:10024'");
226237

227238
exec("postconf -e 'smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf regexp:/etc/postfix/tag_as_originating.re, permit_mynetworks, permit_sasl_authenticated, check_sender_access regexp:/etc/postfix/tag_as_foreign.re'");
228239
}

0 commit comments

Comments
 (0)