Tomcat - Tomcat+Servlet_Javamail+gmail

 
Vista:

Tomcat+Servlet_Javamail+gmail

Publicado por Enrique Ochoa (4 intervenciones) el 13/09/2008 21:47:19
Hola

envio correos sin problema utilizando java standalone+javamail+gmail

sin embargo utilizando una aplicacion web instalada en tomcat 6.0 lanza un error de autenticidad.

el codigo es:

Properties p = new Properties();
p.setProperty("mail.smtp.host", correo.getString("direccion_smtp"));
p.setProperty("mail.smtp.starttls.enable", "true");
p.setProperty("mail.smtp.port", correo.getString("puerto_smtp"));
p.setProperty("mail.smtp.user", correo.getString("email_webmaster"));
p.setProperty("mail.smtp.auth", "true");

Session session = Session.getInstance(p);
session.setDebug(true);

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(correo.getString("email_webmaster")));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
message.setSubject(titulo);
message.setContent(contenido, "text/html");

Transport t = session.getTransport("smtp");
try {
t.connect(correo.getString("email_webmaster"), correo.getString("password_mail"));
message.saveChanges();
t.sendMessage(message, message.getAllRecipients());
} catch (MessagingException e) {throw new Exception("ERROR DE CONEXION AL SERVIDOR DE CORREO " + e.getMessage());}
t.close();

los datos estan almacenados en una base de datos y funciona perfectamente como digo en una aplicacion java simple (standalone)

el log que genera es:

DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false
220 mx.google.com ESMTP m28sm23384251poh.10
DEBUG SMTP: connected to host "smtp.gmail.com", port: 587

EHLO EnriqueOchoa
250-mx.google.com at your service, [189.161.194.165]
250-SIZE 35651584
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35651584"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
STARTTLS
220 2.0.0 Ready to start TLS
EHLO EnriqueOchoa
250-mx.google.com at your service, [189.161.194.165]
250-SIZE 35651584
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
DEBUG SMTP: Found extension "SIZE", arg "35651584"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
Y2VjaWxpYS5hcGVpLkBnbWFpbC5jb20=
334 UGFzc3dvcmQ6
Y2FsaWZvcm5pYQ==
535-5.7.1 Username and Password not accepted. Learn more at

si pueden ayudarme por favor.... gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder