urgent help -java mail authorization failed exception
hi all,
i am developing a feedback form that takes user feed back and send an email to the concerned person. but there is a exception:
Exception:
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<confused.hell@gmail.com>
530-5.5.1 Authentication Required. Learn more at
530 5.5.1 My client isn't accepting my username and password 30sm1751526w ff.8
com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Le arn more at
530 5.5.1 My client isn't accepting my username and password 30sm1751526w ff.8
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(S MTPTransport.java:1 388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTrans port.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr ansport.java:583)
at com.khushiiit.feedback.core.Mail.sendMail(Mail.jav a:63)
at com.khushiiit.feedback.core.MailServlet.doGet(Mail Servlet.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:91)
at com.caucho.server.dispatch.ServletFilterChain.doFi lter(ServletFilterC hain.java:103)
at com.caucho.server.webapp.WebAppFilterChain.doFilte r(WebAppFilterChain .java:181)
at com.caucho.server.dispatch.ServletInvocation.servi ce(ServletInvocatio n.java:266)
at com.caucho.server.http.HttpRequest.handleRequest(H ttpRequest.java:269 )
at com.caucho.server.port.TcpConnection.run(TcpConnec tion.java:603)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPoo l.java:721)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.jav a:643)
at java.lang.Thread.run(Thread.java:595)
exception : com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 My client isn't accepting my username and password 30sm1751526w ff.8
Code:
Properties properties = new Properties();
properties.load(this.getClass().getResourceAsStrea m("resource.properties"));
String user = properties.getProperty("mail.smtp.user");
String password = properties.getProperty("mail.smtp.password");
Authenticator authenticator = new SMTPAuthenticator(user, password);
Session session = Session.getDefaultInstance(properties, authenticator);
session.setDebug(true);
MimeMessage msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(user);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[email.length];
for (int i = 0; i < email.length; i++) {
addressTo[i] = new InternetAddress(email[i].trim());
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
msg.setContent(data, "text/plain");
tr = session.getTransport("smtp");
tr.connect("smtp.gmail.com",user, password);
msg.saveChanges();
tr.sendMessage(msg, msg.getAllRecipients());
tr.close();
one more thing i want to say is that this exception occur when i used resin 3.1.5 as servlet container.
when i run this code in netbeans ide using glassfish as servlet conatiner , my code just work fine .
please get me out of this mess .
thanx in advanced