diff --git a/exec/imapservice.js b/exec/imapservice.js
index f0677b4bafb8c0dae7a927cbc1fa76b7691b09a6..4dc3640c21c00adfd9cd9242ffe7811325c9ed86 100644
--- a/exec/imapservice.js
+++ b/exec/imapservice.js
@@ -184,19 +184,31 @@ function debug_log(line, rx)
 /* Socket I/O */
 /**************/
 
+function full_send(sock, str)
+{
+	var sent = 0;
+	var sret;
+
+	do {
+		sret = sock.send(str.substr(sent));
+		if (sret == undefined)
+			break;
+		sent += sret;
+	} while(sent < str.length);
+}
+
 function tagged(tag, msg, desc)
 {
-	client.socket.send(tag+" "+msg+" "+desc+"\r\n");
+	full_send(client.socket, tag+" "+msg+" "+desc+"\r\n");
 	debug_log("Send: "+tag+" "+msg+" "+desc, false);
 }
 
 function untagged(msg)
 {
-	client.socket.send("* "+msg+"\r\n");
+	full_send(client.socket, "* "+msg+"\r\n");
 	debug_log("Send: * "+msg.length+": "+msg, false);
 }
 
-
 /*************************************************************/
 /* Fetch response generation... this is the tricky bit.  :-) */
 /*************************************************************/
@@ -1788,6 +1800,18 @@ var authenticated_command_handlers = {
 			tagged(tag, "NO", "No appending yet... sorry.");
 		},
 	},
+	NAMESPACE:{
+		arguments: 0,
+		handler:function(args) {
+			var tag=args[0];
+
+			if (user.security.restrictions & UFLAG_G)
+				untagged('NAMESPACE NIL NIL (("" ' + encode_string(sepchar) + '))');
+			else
+				untagged('NAMESPACE (("" ' + encode_string(sepchar) + ')) NIL NIL');
+			tagged(tag, "OK", "Maybe this will get separators to work.");
+		},
+	},
 };
 
 function do_store(seq, uid, item, data)