Can't disable plain login on imap
843834Mar 6 2008 — edited Sep 12 2008I'm trying to write a program that retrieves mail from an imap server. The user name and password won't validate. If I try to connect via pop3 it connects. The mail adminstrator says that I should be able to connect via imap and I am able to using Eudora. The mail adminstrator says we use a cleartext login. I am unable to force imap to use the login method. I have the following line in my properties file to disable Authentication plain.
prop.put("mail.imap.auth.plain.disable",true);
But it still tries to Authenticate plain. Can somebody tell me what I am doing wrong? Here is my code along with the stack trace.
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class ImapRead
{
Properties prop = null;
public ImapRead()
{
prop = new Properties();
prop.put("server", "mail.company.com");
prop.put("mail.imap.host", "mail.company.com");
prop.put("mail.imap.auth.plain.disable",true);
}
public void imapRun()
{
String host = prop.getProperty("server");
String username = prop.getProperty("username");
String password = prop.getProperty("password");
try {
Authenticator auth = new MailAuthenticator();
Session session = Session.getInstance(prop,auth);
session.setDebug(true);
Store store = session.getStore("imap");
store.connect(host,username,password);
store.close();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
public static void main(String[] args)
{
ImapRead mread = new ImapRead();
mread.imapRun();
}
}
Authenticator class
----------------------
mport javax.mail.*;
import java.util.*;
public class MailAuthenticator extends Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
String username = "username@mail.company.com";
String password = "password";
return new PasswordAuthentication(username,password);
}
}
DEBUG: setDebug: JavaMail version 1.4
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK IMAP4 Server (IMail 8.22)
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS AUTH=CRAM-MD5 AUTH=PLAIN AUTH=LOGIN
A0 OK CAPABILITY completed
IMAP DEBUG: AUTH: CRAM-MD5
IMAP DEBUG: AUTH: PLAIN
IMAP DEBUG: AUTH: LOGIN
DEBUG: protocolConnect login, host=mail.ikano.com, user=rlawtest, password=<non-null>
A1 AUTHENTICATE PLAIN
+
cmxhd3Rlc3QAcmxhd3Rlc3QAcmxAdzczNTc=
A1 NO AUTHENTICATE Invalid userid/password
* OK IMAP4 Server (IMail 8.22)
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 UIDPLUS AUTH=CRAM-MD5 AUTH=PLAIN AUTH=LOGIN
A0 OK CAPABILITY completed
IMAP DEBUG: AUTH: CRAM-MD5
IMAP DEBUG: AUTH: PLAIN
IMAP DEBUG: AUTH: LOGIN
DEBUG: protocolConnect login, host=mail.ikano.com, user=rlawtest@mail.ikano.com, password=<non-null>
A1 AUTHENTICATE PLAIN
+
cmxhd3Rlc3RAbWFpbC5pa2Fuby5jb20Acmxhd3Rlc3RAbWFpbC5pa2Fuby5jb20AcmxAdzczNTc=
A1 NO AUTHENTICATE Invalid userid/password
javax.mail.AuthenticationFailedException: AUTHENTICATE Invalid userid/password
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:474)
at javax.mail.Service.connect(Service.java:297)
at javax.mail.Service.connect(Service.java:156)
at com.ikano.mail.ImapRead.imapRun(ImapRead.java:37)
at com.ikano.mail.ImapRead.main(ImapRead.java:61)