From e1ceb050e19c7574bca146a8da7047ee4ff456b5 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Sun, 10 Jul 2016 05:02:35 -0400
Subject: [PATCH] Merge branch 'stable-3.1'

---
 server/plugins-available/postfix_server_plugin.inc.php |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php
index e0de304..64c5571 100644
--- a/server/plugins-available/postfix_server_plugin.inc.php
+++ b/server/plugins-available/postfix_server_plugin.inc.php
@@ -139,6 +139,7 @@
 				}
 			}
 			exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'");
+			exec('postfix reload');
 		}
 		
 		if($mail_config['reject_sender_login_mismatch'] != $old_ini_data['mail']['reject_sender_login_mismatch']) {
@@ -157,23 +158,33 @@
 				array_splice($new_options, $i, 0, array('reject_authenticated_sender_login_mismatch'));
 			}
 			exec("postconf -e 'smtpd_sender_restrictions = ".implode(", ", $new_options)."'");
+			exec('postfix reload');
 		}		
 		
-		if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') {
-			// If dovecot switch to lmtp
-			if($app->system->is_installed('dovecot')) {
-				exec("postconf -e 'virtual_transport = lmtp:unix:private/dovecot-lmtp'");
-			}
-		}
-		else {
-			// If dovecot switch to dovecot
-			if($app->system->is_installed('dovecot')) {
-				exec("postconf -e 'virtual_transport = dovecot'");
+		if($app->system->is_installed('dovecot')) {
+			$temp = exec("postconf -n virtual_transport", $out);
+			if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') {
+				// If dovecot switch to lmtp
+				if($out[0] != "virtual_transport = lmtp:unix:private/dovecot-lmtp") {
+					exec("postconf -e 'virtual_transport = lmtp:unix:private/dovecot-lmtp'");
+					exec('postfix reload');
+					$app->system->replaceLine("/etc/dovecot/dovecot.conf", "protocols = imap pop3", "protocols = imap pop3 lmtp");
+					exec($conf['init_scripts'] . '/' . 'dovecot restart');
+				}
+			} else {
+				// If dovecot switch to dovecot
+				if($out[0] != "virtual_transport = dovecot") {
+					exec("postconf -e 'virtual_transport = dovecot'");
+					exec('postfix reload');
+					$app->system->replaceLine("/etc/dovecot/dovecot.conf", "protocols = imap pop3 lmtp", "protocols = imap pop3");
+					exec($conf['init_scripts'] . '/' . 'dovecot restart');
+				}
 			}
 		}
 
-		exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'");
-		exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'");
+		exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'"); //TODO : no reload?
+		exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'"); //TODO : no reload?
+		
 
 	}
 

--
Gitblit v1.9.1