que tal, pues ahora lo que intento es poder mandar un mail, ya lei la documentacion de javamail, y busque un ejemplito (sin autentificacion) para mandar un mail.
Y yo lo modifique para que se auntenticar de un correo de Yahoo a otro de Yahoo, pero me manda este error:
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
at javax.mail.Service.connect(Service.java:156)
at TestEmail.main(TestEmail.java:51)
Press any key to continue...
este es el codigo:
Código PHP:
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
// Send a simple, single part, text/plain e-mail
public class TestEmail {
public static void main(String[] args) {
// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
String to = "[email protected]";
String from = "[email protected]";
String pass = "mipass";
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = "smtp.mail.yahoo.com";
// Create properties, get Session
Properties props = new Properties();
// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
//props.put("mail.debug", "true");
props.put("mail.smtp.auth","true");
Session session = Session.getInstance(props);
try {
// Instantiatee a message
Message msg = new MimeMessage(session);
//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test E-Mail through Java");
msg.setSentDate(new Date());
// Set message content
msg.setText("This is a test of sending a " +
"plain text e-mail through Java.\n" +
"Here is line 2.");
Transport trans = session.getTransport(address[0]);
trans.connect(host,from,pass);
//trans.send(msg);
trans.sendMessage(msg,address);
//Send the message
//Transport.send(msg);
}
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}
}
}//End of class
No se que estoy haciendo mal, o si alguien me puede decir como.....
p.d: obviamente en el programa original pongo bien mi username y password jeje..
saludos,