diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php
index 8c7f1bae48402fad02f6861919522da0e4f997a2..8f14f9be0f571d3a17ecc67141c61f051cc3f0ef 100644
--- a/install/dist/lib/debian60.lib.php
+++ b/install/dist/lib/debian60.lib.php
@@ -35,6 +35,8 @@ class installer extends installer_base {
 		global $conf;
 		
 		$virtual_transport = 'dovecot';
+
+		$configure_lmtp = false;
 		
 		// check if virtual_transport must be changed
 		if ($this->is_update) {
@@ -44,6 +46,7 @@ class installer extends installer_base {
 			
 			if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
 				$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
+				$configure_lmtp = true;
 			}
 		}
 
@@ -114,7 +117,10 @@ class installer extends installer_base {
 			}
 		}
 		
-		
+		//* dovecot-lmtpd
+		if($configure_lmtp) {
+			replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0);
+		}
 
 		//* dovecot-sql.conf
 		$configfile = 'dovecot-sql.conf';
diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php
index 542092511c52c68ec5b747856bc26cfebc4e7a56..cbc39dea829e2b657502065902617287d8763e28 100644
--- a/install/dist/lib/fedora.lib.php
+++ b/install/dist/lib/fedora.lib.php
@@ -334,6 +334,8 @@ class installer_dist extends installer_base {
 		global $conf;
 
 		$virtual_transport = 'dovecot';
+
+		$configure_lmtp = false;
 		
 		// check if virtual_transport must be changed
 		if ($this->is_update) {
@@ -343,6 +345,7 @@ class installer_dist extends installer_base {
 			
 			if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
 				$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
+				$configure_lmtp = true;
 			}
 		}
 
@@ -415,6 +418,11 @@ class installer_dist extends installer_base {
 			}
 		}
 
+		//* dovecot-lmtpd
+		if($configure_lmtp) {
+			replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0);
+		}
+
 		//* dovecot-sql.conf
 		$configfile = 'dovecot-sql.conf';
 		if(is_file("$config_dir/$configfile")){
diff --git a/install/dist/lib/gentoo.lib.php b/install/dist/lib/gentoo.lib.php
index 6615dacc91f7d7c5fe5acfd0099b649f2f72a4bb..4e04e42111151653a6aa5542bb12d32a66888ac3 100644
--- a/install/dist/lib/gentoo.lib.php
+++ b/install/dist/lib/gentoo.lib.php
@@ -255,6 +255,8 @@ class installer extends installer_base
 		global $conf;
 
 		$virtual_transport = 'dovecot';
+
+		$configure_lmtp = false;
 		
 		// check if virtual_transport must be changed
 		if ($this->is_update) {
@@ -264,6 +266,7 @@ class installer extends installer_base
 			
 			if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
 				$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
+				$configure_lmtp = true;
 			}
 		}
 
@@ -312,6 +315,11 @@ class installer extends installer_base
 		$content = $this->get_template_file('dovecot.conf', true);
 		$this->write_config_file($configfile, $content);
 
+		//* dovecot-lmtpd
+		if($configure_lmtp) {
+			replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0);
+		}
+
 		//* dovecot-sql.conf
 		$configfile = $config_dir.'/dovecot-sql.conf';
 		$content = $this->get_template_file('debian_dovecot-sql.conf', true, true);
diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php
index 59124a5f3dd55b4daba212d9a4b0f5576e4f9710..06dc0e41678447976fd9e36f15accbb2148ec6d5 100644
--- a/install/dist/lib/opensuse.lib.php
+++ b/install/dist/lib/opensuse.lib.php
@@ -342,6 +342,8 @@ class installer_dist extends installer_base {
 		global $conf;
 
 		$virtual_transport = 'dovecot';
+
+		$configure_lmtp = false;
 		
 		// check if virtual_transport must be changed
 		if ($this->is_update) {
@@ -351,6 +353,7 @@ class installer_dist extends installer_base {
 			
 			if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
 				$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
+				$configure_lmtp = true;
 			}
 		}
 
@@ -419,6 +422,11 @@ class installer_dist extends installer_base {
 			}
 		}
 
+		//* dovecot-lmtpd
+		if($configure_lmtp) {
+			replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0);
+		}
+
 		//* dovecot-sql.conf
 		$configfile = 'dovecot-sql.conf';
 		if(is_file("$config_dir/$configfile")){
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 49545c82c009eb167846f08ca72d863a4c12fd1c..2ddea5ed3f7e1c8c0b0fec0177a33c70a59c479d 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -999,6 +999,8 @@ class installer_base {
 		global $conf;
 		
 		$virtual_transport = 'dovecot';
+
+		$configure_lmtp = false;
 		
 		// check if virtual_transport must be changed
 		if ($this->is_update) {
@@ -1008,6 +1010,7 @@ class installer_base {
 			
 			if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
 				$virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
+				$configure_lmtp = true;
 			}
 		}
 
@@ -1078,6 +1081,11 @@ class installer_base {
 			}
 		}
 
+		//* dovecot-lmtpd
+		if($configure_lmtp) {
+			replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0);
+		}
+
 		//* dovecot-sql.conf
 		$configfile = 'dovecot-sql.conf';
 		if(is_file($config_dir.'/'.$configfile)) {
diff --git a/install/tpl/debian6_dovecot2.conf.master b/install/tpl/debian6_dovecot2.conf.master
index ee77f4e20e0416e7638d2be6e306e920ea6340f9..82c7e47a467726119a3588598d797d916fdb05b0 100644
--- a/install/tpl/debian6_dovecot2.conf.master
+++ b/install/tpl/debian6_dovecot2.conf.master
@@ -1,5 +1,5 @@
 listen = *,[::]
-protocols = imap pop3 lmtp
+protocols = imap pop3
 auth_mechanisms = plain login
 disable_plaintext_auth = no
 log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -61,4 +61,4 @@ protocol lda {
 protocol lmtp {
   postmaster_address = webmaster@localhost
   mail_plugins = quota sieve
-}
\ No newline at end of file
+}
diff --git a/install/tpl/debian_dovecot2.conf.master b/install/tpl/debian_dovecot2.conf.master
index 39cf60fbe4de972a87deb006aab7f092284710fb..a753433c512179feb54142be40690087898e18cb 100644
--- a/install/tpl/debian_dovecot2.conf.master
+++ b/install/tpl/debian_dovecot2.conf.master
@@ -1,5 +1,5 @@
 listen = *,[::]
-protocols = imap pop3 lmtp
+protocols = imap pop3
 auth_mechanisms = plain login
 disable_plaintext_auth = no
 log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -62,4 +62,4 @@ protocol lda {
 protocol lmtp {
   postmaster_address = webmaster@localhost
   mail_plugins = quota sieve
-}
\ No newline at end of file
+}
diff --git a/install/tpl/fedora_dovecot2.conf.master b/install/tpl/fedora_dovecot2.conf.master
index 9fca31927487a45358dcc98bc259b1af61c04197..a527676b6541bc887997c1dc0d044689a50acd32 100644
--- a/install/tpl/fedora_dovecot2.conf.master
+++ b/install/tpl/fedora_dovecot2.conf.master
@@ -1,5 +1,5 @@
 listen = *,[::]
-protocols = imap pop3 lmtp
+protocols = imap pop3
 auth_mechanisms = plain login
 disable_plaintext_auth = no
 log_timestamp = "%Y-%m-%d %H:%M:%S "
diff --git a/install/tpl/opensuse_dovecot2.conf.master b/install/tpl/opensuse_dovecot2.conf.master
index 1b9d9dc1555935880984885001fc97a14949ff70..8deb305a4c90a1ae96dba91671e95020b11b6bd5 100644
--- a/install/tpl/opensuse_dovecot2.conf.master
+++ b/install/tpl/opensuse_dovecot2.conf.master
@@ -1,5 +1,5 @@
 listen = *,[::]
-protocols = imap pop3 lmtp
+protocols = imap pop3
 auth_mechanisms = plain login
 disable_plaintext_auth = no
 log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -59,4 +59,4 @@ protocol lda {
 protocol lmtp {
   postmaster_address = webmaster@localhost
   mail_plugins = quota sieve
-}
\ No newline at end of file
+}
diff --git a/server/lib/classes/cron.d/600-purge_mailboxes.inc.php b/server/lib/classes/cron.d/600-purge_mailboxes.inc.php
index 181dd517f6af91cb3c2e7eff0ee5a6984c9d0ad2..59775fb7be2512c9b10fc2a3d74f7149b83a8a5f 100644
--- a/server/lib/classes/cron.d/600-purge_mailboxes.inc.php
+++ b/server/lib/classes/cron.d/600-purge_mailboxes.inc.php
@@ -53,8 +53,8 @@ class cronjob_purge_mailboxes extends cronjob {
 	public function onRunJob() {
 		global $app, $conf;
 
-		$sql = "SELECT email FROM mail_user WHERE maildir_format = 'mdbox' AND server_id = ".$server_id;
-		$records = $app->db->queryAllRecords($sql);
+		$sql = "SELECT email FROM mail_user WHERE maildir_format = 'mdbox' AND server_id = ?";
+		$records = $app->db->queryAllRecords($sql, $server_id);
 		
 		if(is_array($records)) {
 			foreach($records as $rec){
diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php
index f6a55f593010239b1f02f8b15b5e0b5f38c8e4de..87ae500daf7998738be3a0234854fa843758fbb7 100644
--- a/server/plugins-available/postfix_server_plugin.inc.php
+++ b/server/plugins-available/postfix_server_plugin.inc.php
@@ -166,6 +166,8 @@ class postfix_server_plugin {
 			if($app->system->is_installed('dovecot')) {
 				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 {
@@ -173,6 +175,8 @@ class postfix_server_plugin {
 			if($app->system->is_installed('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');
 			}
 		}