Mail::Box::IMAP4
Tom Allison <[email protected]> Mon, 20 Dec 2004 09:08:28 -0500
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <[email protected]> |
~ line 68:
if(@types == 1 && $types[0] eq 'AUTO')
- { @types = ('CRAM-MD5', ($ntml_installed ? 'NTLM' : ()), 'PLAIN');
+ {
+ undef @types;
+ my @supported = qw(PLAIN CRAM-MD5); # Mail::IMAPClient supported
+ foreach (grep {^AUTH=/o} $imap->capability)
+ { my ($mechanism) = /^AUTH=(\w+)/o;
+ # This test only loads AUTH types that are common
+ # between Mail::IMAPClient and the IMAP server
+ next unless grep (/^$mechanism$/, @supported);
+ push @types, $mechanism;
+ }
}
+unless (@types)
+ { die "unable to find a supported authentication method\n" };
Something like that?
I have to admit. I didn't test this directly in the IMAP4.pm module.
But I've gotten this to work on an external script and I believe it
provides the right information for you.
Rather than assuming the authentication @types to be CRAM-MD5, NTLM?,
and PLAIN I ask the IMAP server what it's capalities are for
Authentication ($imap->capability returns all the AUTH mechanisms
supported per RFC2060 section 6.1). This prevents the login process
from hanging on an unsupport authentication model. I haven't been able
to fold in any inquery to Mail::IMAPClient to find out what it's
capabilities are, I just assumed them in the @supported array.
There may be better methods to doing this and I'm ALWAYS open to
improvements. But hopefully this is helpful.