estoy corriendo este sencillo ejemplo con mi cuenta Gmail
, pero no su trabajo y dar el siguiente error:debe emitir un comando STARTTLS primera
send failed, exception: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. nv2sm4478384pbb.6
Aquí está mi código
public class Email
{
public static void main(String [] args)
{
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.googlemail.com");
props.put("mail.from", "[email protected]");
Session session = Session.getInstance(props, null);
try {
MimeMessage msg = new MimeMessage(session);
msg.setFrom();
msg.setRecipients(Message.RecipientType.TO,
"[email protected]");
msg.setSubject("JavaMail hello world example");
msg.setSentDate(new Date());
msg.setText("Hello, world!\n");
Transport.send(msg);
} catch (MessagingException mex) {
System.out.println("send failed, exception: " + mex);
}
}
}
Primero debe emitir un comando STARTTLS. nv2sm4478384pbb.6 – user1226162
Debe agregar la siguiente línea: props.put ("mail.smtp.starttls.enable", "true"); –
Dupe de http://stackoverflow.com/questions/10509699/must-issue-a-starttls-command-first –