public class EnvioSimpleJM
{
public static void main(String[] args)throws IOException, EmailException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", 465);
props.put("mail.smtp.socketFactory.port",465);
props.put("mail.smtp.socketFactory.class","javax.n et.ssl.SSLSocketFactory");
props.put("mail.smtp.auth","true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.socketFactory.fallback","fals e");
Session session = Session.getDefaultInstance(props,new DefaultAuthenticator("
[email protected]","tupassw ord"));
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("
[email protected]","tunombre"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("
[email protected]","nombre receptor"));
message.setSubject("Subject");
message.setText("Mensaje");
Transport t = session.getTransport("smtp");
System.out.println("Conectando");
t.connect();
System.out.println("Enviando");
t.send(message);
System.out.println("Correo Enviado exitosamente!");
t.close();
} catch (Exception e) {
System.out.println("Ops!... " + e.getMessage());
}
}
}