Java - AYUDA JAVAMAIL!!!!!!!!!!!!!!!!!!

 
Vista:

AYUDA JAVAMAIL!!!!!!!!!!!!!!!!!!

Publicado por H (6 intervenciones) el 01/12/2005 16:56:08
Hola estoy utilizando javamail para enviar correos desde una aplicación java.
El problema que tengo es que al ejecutar el código me sale un mensaje de error que no consigo solucionar. El classpath tiene incluidos mail.jar y activation.jar. El código es el siguiente:

void sendCompleteMessage(String addr) throws AddressException, MessagingException{

Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "smtp.correo.yahoo.es");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");




Autentificador authen = new Autentificador();
Session session= Session.getDefaultInstance(props,authen);


session.setDebug(true);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));
msg.setSubject("Report and Grapho of Interacion Analysis");
msg.setRecipient(Message.RecipientType.TO,new InternetAddress(addr));
msg.setSentDate(new Date());

String texto="";
try
{
FileReader fr = new FileReader("fSalida");
BufferedReader entrada = new BufferedReader(fr);
String s;
while((s = entrada.readLine()) != null)
{
texto = texto +s;

}
entrada.close();
}
catch(java.io.FileNotFoundException fnfex){
System.out.println("Archivo no encontrado: " + fnfex);
}
catch(java.io.IOException ioex){
ioex.printStackTrace();
}


msg.setContent(texto,"text/plain");

try{

Transport.send(msg);

}catch(MessagingException mex){
System.out.println(mex.toString());
}
}




public class Autentificador extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = "username";
String password = "contrasegna";
return new PasswordAuthentication(username, password);
}
}
}

Y el error que da:

DEBUG: setDebug: JavaMail version 1.3.3
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 SMTP: trying to connect to host "smtp.correo.yahoo.es", port 25, isSSL false
javax.mail.MessagingException: Could not connect to SMTP host: smtp.correo.yahoo.es, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1227)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:322)
at javax.mail.Service.connect(Service.java:258)
at javax.mail.Service.connect(Service.java:137)
at javax.mail.Service.connect(Service.java:86)
at javax.mail.Transport.send0(Transport.java:150)
at javax.mail.Transport.send(Transport.java:80)
at mail.SendMail.sendCompleteMessage(SendMail.java:145)
at mail.SendMail.<init>(SendMail.java:78)
at IU.Ventana$33.actionPerformed(Ventana.java:733)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
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