Spring ROO have built-in email support
So you can setup email sending properties with following command:
email sender setup --hostServer smtp.gmail.com --username \
<Your email address> --password <Your email password> --port 587 --protocol SMTP
Running the above command results in creation of email.properties that stores the provided email settings.
Now, the rest of email commands can be used to setup email template and inject the template into a controller (or other service class).
So my question is how can I proceed after running above commands so as to move the settings in the email.properties to a database table, and then make the rest of email infrastructure read the settings from that database table? This will make it easier to use the Roo’s scaffolding support to generate UI for updating email settings.
You have to create factory bean.
email.propertiesfileJavaMailSenderin factory method, check for changes in database and updateJavaMailSenderImplobject