Estoy tratando de enviar un simple correo electrónico con este código usando el motor de la aplicación de google. Pero no pasa nada, ¿hay algo que deba configurar para usar la API de correo? Esto se ejecuta en localhost. Estoy usando gmail como host de correo.Enviando un correo electrónico con el motor de la aplicación de google
String host = "smtp.google.com";
String to = "e[email protected]";
String from = "[email protected]";
String subject = "this is a test";
String messageText = "test";
boolean sessionDebug = false;
// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session mailSession = Session.getDefaultInstance(props, null);
// Set debug on the Session
// Passing false will not echo debug info, and passing True will.
mailSession.setDebug(sessionDebug);
// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
¿No hay forma de enviar un correo electrónico desde un proyecto de GAE? ¿O simplemente no usar de esta manera? – Nick
Puede, solo a partir de direcciones específicas y el servidor de desarrollo local simplemente registra los correos electrónicos en la consola – jimr