Gnus development mailing list
 help / color / mirror / Atom feed
* problem in connecting to Exchange 2007 - possible solution?
@ 2007-11-29 23:58 Nathan J. Williams
  2007-12-03 17:04 ` Nathan J. Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan J. Williams @ 2007-11-29 23:58 UTC (permalink / raw)
  To: ding; +Cc: simon, yif


Hi. My company's mail server was just moved to MS Exchange 2007, and I
quickly ran into the IMAP problem described here:

http://article.gmane.org/gmane.emacs.gnus.general/64775

which is that "FETCH 1,* UID" isn't supported by this server, and it
returns with "BAD The specified message set is invalid"

Some experimenting later, I found that "FETCH 1 UID" and "FETCH *:*
UID" work individually to get the lowest and highest number; "FETCH
1,*:* UID" seems to do the same job as "FETCH 1,* UID". A quick patch
followed:

--- nnimap.el.~7.39.~	2007-10-25 04:17:54.000000000 -0400
+++ nnimap.el	2007-11-29 18:55:53.546875000 -0500
@@ -555,7 +555,7 @@
 	      (imap-mailbox-select group examine))
       (let (minuid maxuid)
 	(when (> (imap-mailbox-get 'exists) 0)
-	  (imap-fetch "1,*" "UID" nil 'nouidfetch)
+	  (imap-fetch "1,*:*" "UID" nil 'nouidfetch)
 	  (imap-message-map (lambda (uid Uid)
 			      (setq minuid (if minuid (min minuid uid) uid)
 				    maxuid (if maxuid (max maxuid uid) uid)))


This was sufficent to make things work again for me. Any thoughts as
to whether this is more or less proper than the original, IMAP-wise?
It's certainly good to be able to work with a distressingly common
corporate server.

	- Nathan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problem in connecting to Exchange 2007 - possible solution?
  2007-11-29 23:58 problem in connecting to Exchange 2007 - possible solution? Nathan J. Williams
@ 2007-12-03 17:04 ` Nathan J. Williams
  2007-12-03 18:01   ` Simon Josefsson
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan J. Williams @ 2007-12-03 17:04 UTC (permalink / raw)
  To: ding; +Cc: simon

nathanw@MIT.EDU (Nathan J. Williams) writes:

> Hi. My company's mail server was just moved to MS Exchange 2007, and I
> quickly ran into the IMAP problem described here:
>
> http://article.gmane.org/gmane.emacs.gnus.general/64775
>
> which is that "FETCH 1,* UID" isn't supported by this server, and it
> returns with "BAD The specified message set is invalid"
>
> Some experimenting later, I found that "FETCH 1 UID" and "FETCH *:*
> UID" work individually to get the lowest and highest number; "FETCH
> 1,*:* UID" seems to do the same job as "FETCH 1,* UID". A quick patch
> followed:

I found two other places where a "FETCH *" needed to be replaced by
"FETCH *:*" to get things working properly. Patch follows.

       - Nathan

Index: imap.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/imap.el,v
retrieving revision 7.34
diff -u -r7.34 imap.el
--- imap.el	25 Oct 2007 08:17:54 -0000	7.34
+++ imap.el	3 Dec 2007 16:59:24 -0000
@@ -1735,7 +1736,7 @@
 	  (imap-message-data (make-vector 2 0)))
       (when (imap-mailbox-examine-1 mailbox)
 	(prog1
-	    (and (imap-fetch "*" "UID")
+	    (and (imap-fetch "*:*" "UID")
 		 (list (imap-mailbox-get-1 'uidvalidity mailbox)
 		       (apply 'max (imap-message-map
 				    (lambda (uid prop) uid) 'UID))))
@@ -1779,7 +1780,7 @@
 	  (imap-message-data (make-vector 2 0)))
       (when (imap-mailbox-examine-1 mailbox)
 	(prog1
-	    (and (imap-fetch "*" "UID")
+	    (and (imap-fetch "*:*" "UID")
 		 (list (imap-mailbox-get-1 'uidvalidity mailbox)
 		       (apply 'max (imap-message-map
 				    (lambda (uid prop) uid) 'UID))))
Index: nnimap.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/nnimap.el,v
retrieving revision 7.39
diff -u -r7.39 nnimap.el
--- nnimap.el	25 Oct 2007 08:17:54 -0000	7.39
+++ nnimap.el	3 Dec 2007 16:59:25 -0000
@@ -555,7 +555,7 @@
 	      (imap-mailbox-select group examine))
       (let (minuid maxuid)
 	(when (> (imap-mailbox-get 'exists) 0)
-	  (imap-fetch "1,*" "UID" nil 'nouidfetch)
+	  (imap-fetch "1,*:*" "UID" nil 'nouidfetch)
 	  (imap-message-map (lambda (uid Uid)
 			      (setq minuid (if minuid (min minuid uid) uid)
 				    maxuid (if maxuid (max maxuid uid) uid)))



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problem in connecting to Exchange 2007 - possible solution?
  2007-12-03 17:04 ` Nathan J. Williams
@ 2007-12-03 18:01   ` Simon Josefsson
  2007-12-03 18:14     ` Nathan J. Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Josefsson @ 2007-12-03 18:01 UTC (permalink / raw)
  To: Nathan J. Williams; +Cc: ding

nathanw@MIT.EDU (Nathan J. Williams) writes:

> nathanw@MIT.EDU (Nathan J. Williams) writes:
>
>> Hi. My company's mail server was just moved to MS Exchange 2007, and I
>> quickly ran into the IMAP problem described here:
>>
>> http://article.gmane.org/gmane.emacs.gnus.general/64775
>>
>> which is that "FETCH 1,* UID" isn't supported by this server, and it
>> returns with "BAD The specified message set is invalid"
>>
>> Some experimenting later, I found that "FETCH 1 UID" and "FETCH *:*
>> UID" work individually to get the lowest and highest number; "FETCH
>> 1,*:* UID" seems to do the same job as "FETCH 1,* UID". A quick patch
>> followed:
>
> I found two other places where a "FETCH *" needed to be replaced by
> "FETCH *:*" to get things working properly. Patch follows.

We shouldn't apply this so it is enabled by everyone, because it wastes
bandwidth (sometimes by a large factor, bandwidth goes from O(1) to O(n)
where n is the size of the mailbox...).  Maybe you could rewrite this so
that it is only used if some variable is enabled?

/Simon



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problem in connecting to Exchange 2007 - possible solution?
  2007-12-03 18:01   ` Simon Josefsson
@ 2007-12-03 18:14     ` Nathan J. Williams
  2007-12-04 13:46       ` Simon Josefsson
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan J. Williams @ 2007-12-03 18:14 UTC (permalink / raw)
  To: ding

Simon Josefsson <simon@josefsson.org> writes:

> We shouldn't apply this so it is enabled by everyone, because it wastes
> bandwidth (sometimes by a large factor, bandwidth goes from O(1) to O(n)
> where n is the size of the mailbox...).  Maybe you could rewrite this so
> that it is only used if some variable is enabled?

Does it? "FETCH *:*" seems to only return one message, the last one,
which makes sense to me - it's the range of messages from last to
last. It's not a synonym for "1:*".

	- Nathan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problem in connecting to Exchange 2007 - possible solution?
  2007-12-03 18:14     ` Nathan J. Williams
@ 2007-12-04 13:46       ` Simon Josefsson
  2007-12-04 15:20         ` Nathan J. Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Josefsson @ 2007-12-04 13:46 UTC (permalink / raw)
  To: Nathan J. Williams; +Cc: ding

nathanw@MIT.EDU (Nathan J. Williams) writes:

> Simon Josefsson <simon@josefsson.org> writes:
>
>> We shouldn't apply this so it is enabled by everyone, because it wastes
>> bandwidth (sometimes by a large factor, bandwidth goes from O(1) to O(n)
>> where n is the size of the mailbox...).  Maybe you could rewrite this so
>> that it is only used if some variable is enabled?
>
> Does it? "FETCH *:*" seems to only return one message, the last one,
> which makes sense to me - it's the range of messages from last to
> last. It's not a synonym for "1:*".

Ah, ok, I didn't read carefully.  Still, it seems bad style to send this
to all servers.

Maybe we could have a `imap-dont-send-one-comma-star' variable to toggle
the behaviour, off by default?

If you want, it could be automatically enabled if the server looks like
a exchange server?  Ideally it should set this if the normal command
fails and the 1,*:* approach works, but that might be difficult to do.
Although perhaps, upon login, it could EXAMINE the INBOX and do a FETCH
1,* to check for this, and upon failure test whether 1,*:* works, and if
so, enable the workaround.  It causes some additional round-trips to
open a server, but maybe it is worth it.  Perhaps it could only be done
if the server looks like a exchange server, to avoid slowing down other
servers.

/Simon



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: problem in connecting to Exchange 2007 - possible solution?
  2007-12-04 13:46       ` Simon Josefsson
@ 2007-12-04 15:20         ` Nathan J. Williams
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan J. Williams @ 2007-12-04 15:20 UTC (permalink / raw)
  To: ding

Simon Josefsson <simon@josefsson.org> writes:

>> Does it? "FETCH *:*" seems to only return one message, the last one,
>> which makes sense to me - it's the range of messages from last to
>> last. It's not a synonym for "1:*".
>
> Ah, ok, I didn't read carefully.  Still, it seems bad style to send this
> to all servers.

I agree that it's bad style. I'll investigate a way to do this
conditionally, either with a configuration flag or by somehow
detecting Exchange 2007 (the untagged initial "* OK Microsoft Exchange
Server 2007 IMAP4 service ready" seems like a good thing to work
with), or the broken behavior itself. Mostly I wanted to make sure
this patch was archived somewhere for the next person who encounters
this problem and does a web search on their error message.

	- Nathan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-12-04 15:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-29 23:58 problem in connecting to Exchange 2007 - possible solution? Nathan J. Williams
2007-12-03 17:04 ` Nathan J. Williams
2007-12-03 18:01   ` Simon Josefsson
2007-12-03 18:14     ` Nathan J. Williams
2007-12-04 13:46       ` Simon Josefsson
2007-12-04 15:20         ` Nathan J. Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).