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;
}
CodePudding user response:
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