'Grails - Change mail plugin's configurations dynamically
I'm trying to create an application in grails v. 2.3.4. This app has a feature where every logged in user should be able to send email to anyone and the tricky part here is that I want to let the user to configure its own mail configurations at runtime (configurations are submitted by user in application's front-end).
In other words, change these conf's dynamically:
Taken from config.groovy:
mail {
host = "SMTP SERVER"
port = PORT_NUM
username = "[email protected]"
password = "UsersPassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"PORT_NUM"
]
}
is it possible to do so with this plugin?, is there any other way to do so?
I have already seen this thread and no success: Grails2.1 Dynamic mail configuration
Solution 1:[1]
Forget the mail plugin. You can look at it's source code for reference and sample usage, but you have to work with javamail framework to create your required custom service.
For in-depth reference, see javamail docs here.
For a quick intro, look at this article.
Solution 2:[2]
Look here --> Changing mail configuration in runtime
You can inject the mailSender bean an alter the properties ... didn't found a different way if you want to use the plugin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | styl3r |
| Solution 2 | Community |
