Subject: IMAPD and Perl Net::IMAP module problems

From: Jason Gardiner <[email-masked]>
Date: Thu, 12 Jun 2003 11:07:43 -0400

Hello,

I have written some trivial programs that use Perl to manipulate messages in 
mbx folders.

However, once the number of messages to be manipulated reaches a certain size, 
the programs do not function correctly.  It appears that the problem is the 
way the Perl module passes the commands to IMAPD.

In this instance, I am copying all the messages from the Inbox to another 
folder for processing.  A debug on the Perl program shows that the command is 
issued to the IMAP daemon:

Sending: 5 UID COPY
16600,16601,16602,16603,16604,16605,16606,16607,16608,16609,16610,16611,16612,16
613,16614,16615,16616,16617,16618,16619,16620,16621,16622,16623,16624,16625,1662
6,16627,16628,16629,16630,16631,16632,16633,16634,16635,16636,16637,16638,16639,
16640,16641,16642,16643,16644,16645,16646,16647,16648,16649,16650,16651,16652,16
653,16654,16655,16656,16657,16658,16659,16660,16661,16662,16663,16664,16665,1666
6,16667,16668,16669,16670,16671,16672,16673,16674,16675,16676,16677,16678,16679,
16680,16681,16682,16683,16684,16685,16686,16687,16688,16689,16690,16691,16692,16
693,16694,16695,16696,16697,16698,16699,16700,16701,16702,16703,16704,16705,1670
6,16707,16708,16709,16710,16711,16712,16713,16714,16715,16716,16717,16718,16719,
16720,16721,16722,16723,16724,16725,16726,16727,16728,16729,16730,16731,16732,16
733,16734,16735,16736,16737,16738,16739,16740,16741,16742,16743,16744,16745,1674
6,16747,16748,16749,16750,16751,16752,16753,16754,16755,16756,16757,16758,16759,
16760,167!
61,16762,16763,16764,16765,16766,16767,16768,16769,16770,16771,16772,16773,16774
,16775,16776,16777,16778,16779,16780,16781,16782,16783,16784,16785,16786,16787,1
6788,16789,16790,16791,16792,16793,16794,16795,16796,16797,16798,16799,16800,168
01 /export/home1/cncabuse/mail/HOLDING

If there are more than X number of messages, the debug returns 

Sent 344293 bytes
Read: 7 BAD Command line too long

This leads me to believe that there is a limitation built into the daemon.  
Does anyone know if it's possible to increase the command buffer size?

-- 
Thanks,

Jason Gardiner  CCIE 9297
Sprint NTAC-Internet

There are 10 kinds of people in this world - those that
understand binary and those who don't.
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Thu, 12 Jun 2003 08:22:06 -0700 (PDT)

RFC 2683 recommends that no client should send a command line of more than
1000 octets, and that all IMAP servers should accept a command line of at
least 8000 octets.  The UW IMAP server complies with this recommendation.

Your long command line could have been avoided if you compacted the
request using ranges, that is:
	5 UID COPY 16600:16801 /export/home1/cncabuse/mail/HOLDING

Also, if you want to copy all messages, then:
	tag COPY 1:* /export/home1/cncabuse/mail/HOLDING
will always do the trick.

Although you can probably increase the limit in the server that you are
using, you will always run up against a limit.  All servers will protect
themselves by imposing some limit.

The key is to be sensible in the client, to use ranges whenever possible,
and in a worst case scenario (e.g. "copy every odd sequence numbered
message") break up the command into multiple commands.

I'm actually surprised that c-client didn't break up the command for you.
Are you using the current version of c-client?

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.