diff -ruN dovecot-1.0.alpha1.orig/src/master/mail-process.c dovecot-1.0.alpha1/src/master/mail-process.c
--- dovecot-1.0.alpha1.orig/src/master/mail-process.c	Mon Jul  4 12:30:08 2005
+++ dovecot-1.0.alpha1/src/master/mail-process.c	Sun Sep  4 00:14:48 2005
@@ -227,6 +227,8 @@
 		env_put("FULL_FILESYSTEM_ACCESS=1");
 	if (set->pop3_no_flag_updates)
 		env_put("POP3_NO_FLAG_UPDATES=1");
+	if (set->pop3_reuse_xuidl)
+		env_put("POP3_REUSE_XUIDL=1");
 	if (set->pop3_enable_last)
 		env_put("POP3_ENABLE_LAST=1");
 	if (set->mbox_dirty_syncs)
diff -ruN dovecot-1.0.alpha1.orig/src/master/master-settings.c dovecot-1.0.alpha1/src/master/master-settings.c
--- dovecot-1.0.alpha1.orig/src/master/master-settings.c	Sun Aug  7 13:50:32 2005
+++ dovecot-1.0.alpha1/src/master/master-settings.c	Sun Sep  4 00:14:48 2005
@@ -131,6 +131,7 @@
 	/* pop3 */
 	DEF(SET_BOOL, pop3_no_flag_updates),
 	DEF(SET_BOOL, pop3_enable_last),
+	DEF(SET_BOOL, pop3_reuse_xuidl),
 	DEF(SET_STR, pop3_uidl_format),
 	DEF(SET_STR, pop3_client_workarounds),
 	DEF(SET_STR, pop3_logout_format),
@@ -327,6 +328,7 @@
 	/* pop3 */
 	MEMBER(pop3_no_flag_updates) FALSE,
 	MEMBER(pop3_enable_last) FALSE,
+	MEMBER(pop3_reuse_xuidl) FALSE,
 	MEMBER(pop3_uidl_format) "%v.%u",
 	MEMBER(pop3_client_workarounds) NULL,
 	MEMBER(pop3_logout_format) "top=%t/%T, retr=%r/%R, del=%d/%m, size=%s",
diff -ruN dovecot-1.0.alpha1.orig/src/master/master-settings.h dovecot-1.0.alpha1/src/master/master-settings.h
--- dovecot-1.0.alpha1.orig/src/master/master-settings.h	Sat May 14 20:58:29 2005
+++ dovecot-1.0.alpha1/src/master/master-settings.h	Sun Sep  4 00:14:48 2005
@@ -100,6 +100,7 @@
 	/* pop3 */
 	int pop3_no_flag_updates;
 	int pop3_enable_last;
+	int pop3_reuse_xuidl;
 	const char *pop3_uidl_format;
 	const char *pop3_client_workarounds;
 	const char *pop3_logout_format;
diff -ruN dovecot-1.0.alpha1.orig/src/pop3/commands.c dovecot-1.0.alpha1/src/pop3/commands.c
--- dovecot-1.0.alpha1.orig/src/pop3/commands.c	Tue Jun 28 21:58:17 2005
+++ dovecot-1.0.alpha1/src/pop3/commands.c	Sun Sep  4 00:15:27 2005
@@ -504,6 +504,7 @@
 	};
 	struct var_expand_table *tab;
 	string_t *str;
+	const char *xuidl;
 	int ret, found = FALSE;
 
 	tab = t_malloc(sizeof(static_tab));
@@ -548,7 +549,15 @@
 		str_truncate(str, 0);
 		str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ",
 			    ctx->mail->seq);
-		var_expand(str, uidl_format, tab);
+		if (reuse_xuidl) {
+			xuidl=mail_get_first_header(ctx->mail, "X-UIDL");
+			if (xuidl != NULL)
+				str_append(str, xuidl);
+			else
+				var_expand(str, uidl_format, tab);
+		}
+		else
+			var_expand(str, uidl_format, tab);
 
 		ret = client_send_line(client, "%s", str_c(str));
 		t_pop();
diff -ruN dovecot-1.0.alpha1.orig/src/pop3/common.h dovecot-1.0.alpha1/src/pop3/common.h
--- dovecot-1.0.alpha1.orig/src/pop3/common.h	Sat May 14 20:34:32 2005
+++ dovecot-1.0.alpha1/src/pop3/common.h	Sun Sep  4 00:14:48 2005
@@ -18,7 +18,7 @@
 
 extern struct ioloop *ioloop;
 extern enum client_workarounds client_workarounds;
-extern int enable_last_command, no_flag_updates;
+extern int enable_last_command, no_flag_updates, reuse_xuidl;
 extern const char *uidl_format, *logout_format;
 extern enum uidl_keys uidl_keymask;
 
diff -ruN dovecot-1.0.alpha1.orig/src/pop3/main.c dovecot-1.0.alpha1/src/pop3/main.c
--- dovecot-1.0.alpha1.orig/src/pop3/main.c	Sat May 14 21:16:41 2005
+++ dovecot-1.0.alpha1/src/pop3/main.c	Sun Sep  4 00:14:48 2005
@@ -41,6 +41,7 @@
 enum client_workarounds client_workarounds = 0;
 int enable_last_command = FALSE;
 int no_flag_updates = FALSE;
+int reuse_xuidl = FALSE;
 const char *uidl_format, *logout_format;
 enum uidl_keys uidl_keymask;
 
@@ -174,6 +175,7 @@
 	parse_workarounds();
 	enable_last_command = getenv("POP3_ENABLE_LAST") != NULL;
 	no_flag_updates = getenv("POP3_NO_FLAG_UPDATES") != NULL;
+	reuse_xuidl = getenv("POP3_REUSE_XUIDL") != NULL;
 
 	uidl_format = getenv("POP3_UIDL_FORMAT");
 	if (uidl_format == NULL)
