Authentication failed Exception.... please help....

i am new to javamail.....

this is my first application in javamail....

sendingmail.java

import javax.mail.*;

import javax.mail.internet.*;

import java.util.*;

public class sendingmail

{

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

{

Properties p=System.getProperties();

p.put("mail.smtp.host", s[0]);

p.put("mail.smtp.port", s[1]);

Session se=Session.getDefaultInstance(p,null);

Transport t=se.getTransport("smtp");

Message m=new MimeMessage(se);

m.setFrom(new InternetAddress("santosh"));

m.setSubject("MySubject");

m.setSentDate(new Date());

m.setText("bye...bye...");

m.setRecipient(Message.RecipientType.TO,new InternetAddress("san"));

t.send(m);

System.out.println("Message sent....");

}

}

receivingmail.java

import javax.mail.*;

import javax.mail.internet.*;

import java.util.*;

public class receivingmail

{

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

{

Properties p=System.getProperties();

p.put("mail.pop3.host", s[0]);

p.put("mail.pop3.port", s[1]);

Session se=Session.getDefaultInstance(p,new MyAuthenticator());

Store st=se.getStore("pop3");

st.connect();

Folder f=st.getFolder("Inbox");

f.open(Folder.READ_ONLY);

Message m[]=f.getMessages();

for(int i=0;i<m.length;i++)

{

System.out.println("Mail:"+(i+1));

System.out.println("From:"+m.getFrom()[0]);

System.out.println("Subject:"+m.getSubject());

System.out.println("Sent Date:"+m.getSentDate());

System.out.println("Content:"+m.getContent());

}

f.close(true);

st.close();

}

}

MyAuthenticator.java

import javax.mail.*;

import javax.mail.internet.*;

import java.util.*;

import java.io.*;

public class MyAuthenticator extends Authenticator

{

public MyAuthenticator(){}

protected PasswordAuthentication getPasswordAuthentication()

{

try

{

DataInputStream dis=new DataInputStream(System.in);

System.out.println("Enter your Name:");

user=dis.readLine();

System.out.println("Enter your Password:");

pass=dis.readLine();

}

catch(Exception e){}

return new PasswordAuthentication(user,pass);

}

String user,pass;

}

error is.....

Exception in thread "main" javax.mail.AuthenticationFailedException: Authentication failed.

at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:104)

at javax.mail.Service.connect(Service.java:256)

at javax.mail.Service.connect(Service.java:135)

at javax.mail.Service.connect(Service.java:87)

at receivingmail.main(receivingmail.java:13)>

[2943 byte] By [Santosh_Gadagojua] at [2007-11-27 11:53:25]
# 1

The JavaMail FAQ has some tips on debugging such problems.

bshannona at 2007-7-29 18:50:10 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...