Issue
I am not able to send mail in spring boot I have written the whole configuration right for sending mail but its not working I am not able to solve this problem.
This is my bean for sending mail
@Bean
public JavaMailSender getJavaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);
mailSender.setUsername("xxxxxx");
mailSender.setPassword("fubwbpumstgwnxef");
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.debug", "true");
return mailSender;
}
Solution
Have you added this in your applications properties also like this:
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=xxxxxxxxx
spring.mail.password=xxxxxxxxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.main.allow-bean-definition-overriding=true
Answered By – Sourabh Kundu
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0