javamail y tomcat
Publicado por Edu (2 intervenciones) el 24/11/2006 13:02:19
ola a todos,
he creado una aplicacion q manda correos con javamail con SMTP y tomcat.
Los correos llegan sin ningun problema.
El problema esta cuando varias peticiones de correo se solicitan por usuarios a la vez (o casi a la vez, un par de segundos), Los correos llegan al ultimo de los usuarios q hicieron la peticion y los otros no reciben nada.
No se si sera por un problema del codigo o del tomcat q se lia, xq como ya he dixo cuando entre peticion y peticion hay unos segundos, los correos llegan bien.
Este es el codigo:
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getInstance(props, null);
// Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Pedido para Suscripciones");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("Se adjunta un fichero con el justificante del pedido.");
// Create a Multipart
Multipart multipart = new MimeMultipart();
// Add part one
multipart.addBodyPart(messageBodyPart);
//
// Part two is attachment
//
// Create second body part
messageBodyPart = new MimeBodyPart();
// Get the attachment
javax.activation.DataSource source = new javax.activation.FileDataSource(filename);
// Set the data handler to the attachment
messageBodyPart.setDataHandler(new DataHandler(source));
// Set the filename
messageBodyPart.setFileName(filename);
// Add part two
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message);
Si alguien me pudiera aconsejar algo u optomizar esto se lo agradeceria, GRACIAS
he creado una aplicacion q manda correos con javamail con SMTP y tomcat.
Los correos llegan sin ningun problema.
El problema esta cuando varias peticiones de correo se solicitan por usuarios a la vez (o casi a la vez, un par de segundos), Los correos llegan al ultimo de los usuarios q hicieron la peticion y los otros no reciben nada.
No se si sera por un problema del codigo o del tomcat q se lia, xq como ya he dixo cuando entre peticion y peticion hay unos segundos, los correos llegan bien.
Este es el codigo:
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getInstance(props, null);
// Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Pedido para Suscripciones");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("Se adjunta un fichero con el justificante del pedido.");
// Create a Multipart
Multipart multipart = new MimeMultipart();
// Add part one
multipart.addBodyPart(messageBodyPart);
//
// Part two is attachment
//
// Create second body part
messageBodyPart = new MimeBodyPart();
// Get the attachment
javax.activation.DataSource source = new javax.activation.FileDataSource(filename);
// Set the data handler to the attachment
messageBodyPart.setDataHandler(new DataHandler(source));
// Set the filename
messageBodyPart.setFileName(filename);
// Add part two
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message);
Si alguien me pudiera aconsejar algo u optomizar esto se lo agradeceria, GRACIAS
Valora esta pregunta


0