javax.mail.AuthenticationFailedException: Invalid login

Hi,

I have a piece of code that works fine with imap but when I am using it for pop3 ,it doesn't work.

It gives the following exception.

javax.mail.AuthenticationFailedException: Invalid login

at com.sun.mail.pop3.POP3Store.protocolConnectPOP3Store.java:146)

at javax.mail.Service.connect(Service.java:275)at javax.mail.Service.connect(Service.java:156)

at mailDownload.MailReader.main(MailReader.java:30)

My Code :

package mailDownload;

import java.io.*;

import javax.mail.*;

public class MailReader

{

public static void main(String args[]) throws Exception

{

String host = "xxx.xxx.com";

String username = "xxxx";

String password = "xxxx";

// Get session

Session session = Session.getInstance(System.getProperties(), null);

// Get the store

Store store = session.getStore("pop3");

System.out.println("Connecting... ");

store.connect(host, username, password);

// Get folder

System.out.println("reading the Inbox.. ");

Folder folder = store.getFolder("INBOX");

folder.open(Folder.READ_ONLY);

...it continues...

Please help....

Thanks in advance..

Hari

[1246 byte] By [hdevarapallia] at [2007-10-3 9:20:00]
# 1
Looks like your server doesn't believe that you're supplying thecorrect user name and password.
bshannona at 2007-7-15 4:33:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
But with the same details I could retreive messages from the server using imap.
hdevarapallia at 2007-7-15 4:33:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

> But with the same details I could retreive messages

> from the server using imap.

POP and IMAP support different authentication mechanisms. Your

server may be configured to require an authentication mechanism

that JavaMail supports for IMAP, but not for POP3. You probably

need to talk to your server administrator. The protocol trace might

give you some clues as well.

bshannona at 2007-7-15 4:33:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
I fixed this problem.....if ur user name is xyz@abc.com imap works with user name as xyz or xyz@abc.com but pop3 will work only if username is given xyz@abc.com .Regards,hari
hdevarapallia at 2007-7-15 4:33:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Properties pop3Props = new Properties();

pop3Props.setProperty("mail.pop3.port", "110");

URLName url = new URLName("pop3", "mailserveruerconnect.com", 110, "",

username, password);

session = Session.getInstance(pop3Props, null);

store = new POP3Store(session, url);

Message was edited by:

javaskilled

javaskilleda at 2007-7-15 4:33:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

> I fixed this problem.....

>

> if ur user name is xyz@abc.com

>

> imap works with user name as xyz or xyz@abc.com

> but pop3 will work only if username is given

> xyz@abc.com .

That's not an attribute of the pop3 protocol, it's just the way

your pop3 server happens to work. But I'm glad you figured

it out.

bshannona at 2007-7-15 4:33:16 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7

> Properties pop3Props = new Properties();

> pop3Props.setProperty("mail.pop3.port", "110");

> URLName url = new URLName("pop3", "mailserveruerconnect.com", 110, "",

>username, password);

> session = Session.getInstance(pop3Props, null);

> store = new POP3Store(session, url);

I don't know what the point of posting this code was, but I want

to make sure people know that that is not the way to access

a pop3 store. The correct approach is illustrated in many sample

programs included with the JavaMail download bundle.

All you need is:

session = Session.getInstance(props, null);

store = session.getStore("pop3");

store.connect(host, user, password);

bshannona at 2007-7-15 4:33:16 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...