As you can add environment variables in Spring-Boot in email data in the applitacation.properties file? In my case I use Linux and configure the environment variables in /etc/environment
It work with
spring.datasource.url=${SPRING_DATASOURCE_URL}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
But it doesn't work with
spring.mail.host=${SPRING_MAIL_HOSTNAME}
spring.mail.port=${SPRING_MAIL_PORT}
spring.mail.username=${SPRING_MAIL_USERNAME}
spring.mail.password=${SPRING_MAIL_PASSWORD}
what is the difference in this?
CodePudding user response:
It should work, but you doesn't specify what is not working. To make these properties useful you have to wire the right Spring Boot plugin and obviously use it in your code:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.7.0</version>
</dependency>
// wire it in your bean
@Autowired
private JavaMailSender emailSender;
// reference the emailSender and send emails ...