Ayuda con javamail
Publicado por Francisco (9 intervenciones) el 14/05/2006 20:12:53
Estoy intentando usar javamail con el siguiente codigo:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception {
String host = "smtp.telefonica.net";
String from = "[email protected]";
String to = "[email protected]";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.port", "25");
props.put("mail.smtp.host", host);
//Authenticator auth=new PopupAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set the subject
message.setSubject("Hello JavaMail");
// Set the content
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
}
}
Está bajado de internet, y según el artículo debe funcionar, pero tengo la siguiente excepcion.
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: smtp.telefonica.net;
nested exception is:
java.net.UnknownHostException: smtp.telefonica.net
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at MailExample.main(MailExample.java:39)
Y no entiendo por qué, pues mi servidor de correo SMTP está bien puesto.
Gracias anticipadas por la ayuda
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception {
String host = "smtp.telefonica.net";
String from = "[email protected]";
String to = "[email protected]";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.port", "25");
props.put("mail.smtp.host", host);
//Authenticator auth=new PopupAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set the subject
message.setSubject("Hello JavaMail");
// Set the content
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
}
}
Está bajado de internet, y según el artículo debe funcionar, pero tengo la siguiente excepcion.
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: smtp.telefonica.net;
nested exception is:
java.net.UnknownHostException: smtp.telefonica.net
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at MailExample.main(MailExample.java:39)
Y no entiendo por qué, pues mi servidor de correo SMTP está bien puesto.
Gracias anticipadas por la ayuda
Valora esta pregunta


0