com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first

I think you have to specify that you are sending a TLS email before sending the email.

mail.setTLS(true);

I am not 100% sure but I think it might solve the problem.

Also for more info you can refer to this user guide: https://commons.apache.org/proper/commons-email/userguide.html


I found that the working solution to this problem.

Here's the code:

Properties properties = new Properties();
properties.put("mail.smtp.host", mailAccount.getMailHost());
properties.put("mail.smtp.port", mailAccount.getPort());
properties.put("mail.smtp.auth", mailAccount.isAuth());
properties.put("mail.smtp.starttls.enable",mailAccount.isStartTls());