Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Authentication Failed

Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Authentication Failed

Hi, i am trying to send an email using a java program but i keep getting this error, i have tried 4 different accounts and still the same thing.

This is my code which i store in the application.properties file :

spring.mail.host=smtp.zoho.com
spring.mail.port=465
spring.mail.username= myemail
spring.mail.password= mypassword
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.protocol=smtp

When i use the port 465 i get this error :

Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.zoho.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.zoho.com, port: 465, response: -1

When i use port 587 i get this error :

Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Authentication Failed

The same code is working if i use gmail. I tried the solution given here https://help.zoho.com/portal/community/topic/could-not-connect-to-smtp-host-smtp-zoho-com-port-465-response-1 and it didnt work still.