O SMTP do GMail exige o SSL pela porta 465 e TLS pela porta 587, ambos ativos, mas não sei como adicionar as duas portas no código diferenciando as.
mailSender.setPort(587); mailSender.setPort(465); // ???
mailProperties.put("mail.smtp.starttls.enable", true); mailProperties.put("mail.smtp.startssl.enable", true); //???
@Bean
public MailSender mailSender(){
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setUsername("myEmail@gmail.com");
mailSender.setPassword("myPassword");
mailSender.setPort(587);
mailSender.setDefaultEncoding("UTF-8");
Properties mailProperties = new Properties();
mailProperties.put("mail.smtp.auth", true);
mailProperties.put("mail.smtp.starttls.enable", true);
mailSender.setJavaMailProperties(mailProperties);
return mailSender;
}