Ver Mensaje Individual
  #15 (permalink)  
Antiguo 07/05/2009, 06:09
Avatar de SileBird
SileBird
 
Fecha de Ingreso: abril-2009
Ubicación: http://silekun.elbruto.es
Mensajes: 75
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Correos en JSP

Bueno, despues de todo no funciona...

Código:
import java.util.*;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.apache.commons.mail.*;

import java.io.*;

public class EnvioSimpleJM
{
	public static void main(String[] args)throws IOException, EmailException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		try {
			Properties props = new Properties();
			
			props.put("mail.smtp.host", "smtp.ornalux.com");
			props.put("mail.smtp.port", 25);
			props.put("mail.smtp.socketFactory.port",25);
			props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
			props.put("mail.smtp.auth","true");
			props.put("mail.smtp.starttls.enable", "true");
			props.put("mail.debug", "true");
			props.put("mail.smtp.socketFactory.fallback","false");
			
			Session session = Session.getDefaultInstance(props,new DefaultAuthenticator("[email protected]","tupassw ord"));
			
			MimeMessage message = new MimeMessage(session);
			message.setFrom(new InternetAddress("[email protected]","Tomás"));
			message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]","Hugo"));
			
			
			message.setSubject("Subject");
			message.setText("Mensaje");
			
			Transport t = session.getTransport("smtp");
			System.out.println("Conectando");
			t.connect();
			System.out.println("Enviando");
			Transport.send(message);
			System.out.println("Correo Enviado exitosamente!");
			
			t.close();
			
		} catch (Exception e) {
			System.out.println("Ops!... " + e.getMessage());
		}
	}
}
Lo que está en Verde es donde falla y salta el error, pues en la consola acaba diciendo Conectando y luego "Ops!... Exception reading response"

Tabién se puede ver en la consola algo que no me gusta nada:

Código:
DEBUG: JavaMail version 1.4.2
DEBUG: URL jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/imap.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/imap.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/pop3.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/pop3.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: URL jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/smtp.jar!/META-INF/javamail.address.map
DEBUG: successfully loaded resource: jar:file:/C:/Documents%20and%20Settings/hmunoz/Escritorio/javamail-1.4.2/lib/smtp.jar!/META-INF/javamail.address.map
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
Conectando
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.ornalux.com", port 25, isSSL false
DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
Ops!... Exception reading response
Me seguiré pegando con ello y mirando que es "javax.net.ssl.SSLException"