Re: Mail::Transport::IMAP4 bug

Mark Overmeer <[email protected]> Wed, 25 May 2005 10:59:18 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Raul Dias ([email protected]) [050525 06:41]:
> When a Mail::Box::IMAP4 is created, the Mail::Transport::IMAP4 
> calls authentication() during init() with the authentication form
> choosen (or AUTO).
> 
> The problem is that this has not being saved in the first call, 
> because it returns undef because of a imapClient() call.

Well, close (enough)  The problem is caused by the fact that I wanted
to reduce the list of specified authentication method with the list
supported by the server.  But I do that before there is a contact with
the server... which doesn't work.

Now I also understand why I saw people creating their own IMAPClient
object before opening the folder.  The Mail::Box::IMAP4 folder type
is capable of creating it transparently, so why the hassle, I thought.
Probably because of the problem you highlight here. Thanks for reporting
it: my test-suite at home is unsufficient.

> The solution is to place the first authentication() call after
> the imapClient has being saved.

Well, that would require everyone to create the IMAPClient object
explicitly, which I do not want.

The solution is simply to delay the reduction in list of authentication
methods to the moment the connection is established/being build.

I have changed the implementation of sub authenticate() to do a
better job.  This will come to you in a separate mail.  Can you
try it?

> BTW, I spoted a bug in Mail::IMAPClient when doing a CRAM-MD5
> authentication against a Cyrus-Imapd server without authentication
> mechanism (other than PLAIN).  In this case Mail::IMAPClient will hang
> forever.

I have quite bad experiences in my attempts getting bugs in IMAPClient
fixed.  Hope you get better results.  Or maybe someone can take over
its maintenance...  I have quite a long list of improvements...
The code hasn't been updated in 18 months.

> I have mailed the Mail::IMAPClient author, but I suggest that when
> authenticate is 'AUTO' it should try plain 'PLAIN' before 'CRAM-MD5'.

No, that is not a good solution: connection attempts should go from
most-secure to insecure.

> The last thing I noticed is when authenticating with wrong credentials,
> Mail::Transport::IMAP4 will loop forever in login, because 'retries' by
> default is -1 which means forever.

That is because Mail::Box is a library, not an end-user application.
If you write a mail-client for users, you wish an interaction with the
user on every attempt.  However, as an automated mail application, you
do not want the application to fail when the server is temporary
unavailable or misconfigured.
  The (expected) performance (for some of the folder types) of MailBox
(being mainly written in Perl) is probably not really sufficient for
interactive applications. [Although I have heard other statements, I have
no experience with that]  Therefore, the defaults are usually tuned towards
optimal behaviour for automatic clients.  In this case: try until you die.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net