Authenticates but throws AuthenticationFailedException?!?!?
I have got the following code used for sending a simple mail over a SMTP with Authentication connection.
boolean debug =true;
// Create a mail session
java.util.Properties props =new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port",""+smtpPort);
props.put("mail.smtp.auth","true");
Authenticator passwordAuth =new SMTPAuthenticator(from,passFrom);
Session session = Session.getDefaultInstance(props,null);
session.setDebug(debug);
Transport transport = session.getTransport("smtp");
// Construct the message
Message msg =new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO,new InternetAddress(to));
msg.setSubject(subject);
msg.setText(content);
// Send the message
transport.connect("hostname","loginame","password");
//transport.connect();
transport.send(msg);
Now there comes the funny part:
DEBUG SMTP: connected to host "hostname", port: 25
EHLO SIECSC_SDS03
250-hostnamehostname
250-PIPELINING
250-SIZE 2556000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "2556000"
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
Z2dhbHZhbw==
334 UGFzc3dvcmQ6
YXB0NTAz
235 2.0.0 Authentication successful
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at br.gov.trern.siasf.util.MailSender.send(MailSender.java:73)
at br.gov.trern.siasf.util.MailSender.sendMail(MailSender.java:85)
at br.gov.trern.siasf.util.TesteMail.main(TesteMail.java:28)
Now, that's really crazy. Firstly it says: Authentication Succesful, then it says AuthenticationFailedException! w00t?
Message was edited by:
Gabriel.Galvao

