Read emial parameters from database not from application.properties

Hi,
How can i send email using jmix email addon but without setting email parameters in aplication.properties file ? I take them from a database.

aplication.properties
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.protocol=smtp
spring.mail.username=username
spring.mail.password=password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

*** e-mail class
EmailInfo emailInfo = EmailInfoBuilder.create()
.setAddresses(“john.doe@company.com,jane.doe@company.com”)
.setSubject(newsItem.getCaption())
.setFrom(null)
.setBody(newsItem.getContent())
.setAttachments(emailAtt)
.build();
emailer.sendEmailAsync(emailInfo);

@ghircoiascamil

Please look this post Email - Setting parameters for mail account at runtime

It is was you are looking for. Have a good day.

1 Like