| Newsgroups |
gmane.comp.java.javaspain |
| Message-ID |
<[email protected]> |
Estimados Listeros...
Tengo un programa que se encarga de enviar mails., pero me da un error,
hace tiempo dejo de funcionar.
Lo utilizo con Yahoo y el mensaje de error es el siguiente:
DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.mail.yahoo.com.ar", port 25
220 smtp111.mail.mud.yahoo.com ESMTP
DEBUG SMTP: connected to host "smtp.mail.yahoo.com.ar", port: 25
EHLO ISPC009
250-smtp111.mail.mud.yahoo.com
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250 8BITMIME
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XYMCOOKIE"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
aXNfYmFja3Vwc19lbnZpYQ==
334 UGFzc3dvcmQ6
aW5nZWxob3Juc2lzdGVtYXM=
535 authorization failed (#5.7.0)
Error:javax.mail.AuthenticationFailedException
Visité la pagina de Yahoo, y los parametros actuales son :
* smtp.mail.yahoo.com.ar
* puerto 465
* SSL
por lo tanto, y considerando que el puerto por defecto es 25, probé
agregando la siguiente linea para corregir el puerto:
props.put("mail.smtp.port", "465");
y me dio el siguiente error:
DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.mail.yahoo.com.ar", port 465
DEBUG SMTP: exception reading response: java.net.SocketException:
Connection res
et
Error:javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
Estoy considerando la posibilidad de que el error se da porque no
especifico SSL, como podria especificar que se utilice SSL ?
Ahora bien, intenté con una cuenta Gmail, siendo los parametros de gmail
los siguientes....
*El servidor de correo saliente (SMTP) requiere TLS:*
smtp.gmail.com(usar autenticación)
*Usar autenticación*: SÃ
*Usar STARTTLS*: SÃ (en algunos clientes se denomina SSL)
*Puerto*: 465 ó 587
y los mensajes de error son iguales que con los parametros de Yahoo.
Cual es el inconveniente ?
Muchas Gracias
Pablo
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.*;
public class EnviaCorreoYahoo {
public EnviaCorreoYahoo() {
}
public static void main(String args[]) {
String Desde = "usuarioyahoo-/[email protected]";
String Para = "[email protected]";
String Servidor_pop = "pop.mail.yahoo.com.ar";
String Servidor_smtp = "smtp.mail.yahoo.com.ar";
String Usuario = "usuarioyahoo";
String Clave = "clavecuentayahoo";
String Asunto = "Asunto del mail";
String Mensaje = "Mensaje del mail";
Properties props = new Properties();
props.put("mail.smtp.host", Servidor_smtp);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session s = Session.getInstance(props);
s.setDebug(true);
MimeMessage message = new MimeMessage(s);
try {
InternetAddress from = new InternetAddress(Desde);
message.setFrom(from);
InternetAddress to = new InternetAddress(Para);
message.addRecipient(javax.mail.Message.RecipientType.TO, to);
message.setSubject(Asunto);
message.setText(Mensaje);
message.saveChanges();
Transport transport = s.getTransport("smtp");
transport.connect(Servidor_smtp, Usuario, Clave);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
} catch(Exception e) {
System.out.println("Error:" + e.toString());
}
}
}