Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SMTP AuthenticationFaildException when connecting from mail java app

843834May 24 2010 — edited May 25 2010
Hello,

I'm experiencing the following issue when I try to authenticate to the SMTP server of a customer of mine from my java app:

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true

DEBUG: SMTPTransport trying to connect to host "out.alice.it", port 25

DEBUG SMTP RCVD: 220 FBCMCL01B08.fbc.local Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Fri, 14 May 2010 15:03:57 +0200

DEBUG: SMTPTransport connected to host "out.alice.it", port: 25

DEBUG SMTP SENT: EHLO P350
DEBUG SMTP RCVD: 250-FBCMCL01B08.fbc.local Hello [94.83.244.82]
250-TURN
250-SIZE 104857600
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK

DEBUG SMTP: Attempt to authenticate
DEBUG SMTP SENT: AUTH LOGIN
DEBUG SMTP RCVD: 334 VXNlcm5hbWU6

DEBUG SMTP SENT: Z3VpZG90dGkxOTI1QGFsaWNlLml0
DEBUG SMTP RCVD:
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.AuthenticationFailedException
at com.geasoft.GhostMail.Server.Sender.sendMail(Sender.java:509)
at com.geasoft.GhostMail.Server.Sender.endElement(Sender.java:292)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at com.geasoft.GhostMail.Server.Sender.<init>(Sender.java:123)
at com.geasoft.GhostMail.Server.MailDeamon.run(MailDeamon.java:310)
at java.lang.Thread.run(Unknown Source)
ORA -->> 15035870

While I can connect to the server via telnet:

220 FBCMCL01B06.fbc.local Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Mon, 24 May 2010 11:15:09 +0200
EHLO
250-FBCMCL01B06.fbc.local Hello [89.97.253.162]
250-TURN
250-SIZE 104857600
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK
AUTH LOGIN
334 VXNlcm5hbWU6
Z3VpZG90dGkxOTI1QGFsaWNlLml0
334 UGFzc3dvcmQ6
YWxidjc3ZXM=
235 2.7.0 Authentication successful.

Many others customers of mine are running the same app without any problem. Here is the code I'm using to send emails:

Properties props = new Properties();
props.put("mail.smtp.host","out.alice.it");
props.put("mail.smtp.auth", "true");
Session session = Session.getInstance(props, new MyAuthenticator(username, password));
SMTPTransport t = (SMTPTransport)session.getTransport("smtp");
try {
t.connect("out.alice.it", username, password);
t.sendMessage(msg, msg.getAllRecipients());
} catch (Exception e){
e.printStackTrace();
} finally {
t.close();
}

...
...

class MyAuthenticator extends Authenticator{
private String userName, passWord;

public MyAuthenticator(String user, String passwd){
super();
userName = user;
passWord = passwd;
}

public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, passWord);
}
}


I've also analyzed the net traffic with WireShark analyzer and I saw the SMTP server responded to my java app with a TCP packet with the RST flag set after sending the base64 encoded user name.

Any clue?
Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2010
Added on May 24 2010
4 comments
3,094 views