Cita:
Pero me falla en la línea:<%@ page import = "java.util.HashMap,java.util.Vector,java.util.*,ja va.io.*,javax.mail.*,javax.mail.internet.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
//Enviamos el e-mail
String to = [email protected];
Date sentDate=new Date();
String from="[email protected]";
String subject="Concepto del mensaje";
String mensaje="cuerpo del mensaje";
String servidor="smtp.gmail.com";
String user=" mi_email @gmail.com";
String passEmail="contraseña";
int estado=0;
String mensa="";
String mensa1="";
try
{
Properties props = new Properties();
props.put("mail.smtp.host", servidor);
Session newses = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(newses);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(sentDate);
msg.setText(mensaje);
msg.saveChanges();
Transport transport = newses.getTransport("smtp");
Store store = newses.getStore("pop3");
store.connect(servidor, user, passEmail);
transport.connect(servidor, user, passEmail);
transport.sendMessage(msg, msg.getAllRecipients());
}
catch (Exception e)
{
}
%>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
//Enviamos el e-mail
String to = [email protected];
Date sentDate=new Date();
String from="[email protected]";
String subject="Concepto del mensaje";
String mensaje="cuerpo del mensaje";
String servidor="smtp.gmail.com";
String user=" mi_email @gmail.com";
String passEmail="contraseña";
int estado=0;
String mensa="";
String mensa1="";
try
{
Properties props = new Properties();
props.put("mail.smtp.host", servidor);
Session newses = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(newses);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(sentDate);
msg.setText(mensaje);
msg.saveChanges();
Transport transport = newses.getTransport("smtp");
Store store = newses.getStore("pop3");
store.connect(servidor, user, passEmail);
transport.connect(servidor, user, passEmail);
transport.sendMessage(msg, msg.getAllRecipients());
}
catch (Exception e)
{
}
%>
</body>
</html>
store.connect(servidor, user, passEmail);
Dándome el error:
javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Connection timed out: connect
¿Alguna idea de cómo solucionarlo?
Gracias!!