I have written an email service using Spring Email and then used Greenmail to test the email service. But while running the test case it gives an error Authentication failed as below:
javax.mail.AuthenticationFailedException: 535 5.7.0 Authentication credentials invalid at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965) at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
How can this error be resolved without giving my username/password in the code. Note that I have also tried giving username/password but it failed with the same exception. Thanks for any help.
Looks like you don't added the mock credentials i.e. a a resource file called
application-test.ymlfile which is located in thesrc/test/resourcesfolder.application.yml
You can take a look an example by following link:
https://memorynotfound.com/spring-mail-integration-testing-junit-greenmail-example/