{"id":2719,"date":"2011-02-03T12:53:14","date_gmt":"2011-02-03T07:23:14","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=2719"},"modified":"2016-12-19T15:04:08","modified_gmt":"2016-12-19T09:34:08","slug":"mail-plugin-with-db-driven-configuration","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/mail-plugin-with-db-driven-configuration\/","title":{"rendered":"Grails Mail Plugin with DB Driven configuration"},"content":{"rendered":"<p>We have been coming across a certain use case in a couple of projects that the Email credentials\/settings used for sending email should be different based on the from address. This is because the applications act as software services that are used by different organizations, which operate in the same business. And each needed their own customized emails and use their email credentials for sending of mails.<\/p>\n<p>After searching a lot for such a solution, we found that such a <a title=\"TO THE NEW Grails Developers Team\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">use case has arisen for quite a few developers<\/a>.<\/p>\n<p>Another demand was that a mail service provider like GMail be used to send emails instead of using a mail server like Postfix of Sendmail.<\/p>\n<p>What we came up was a modified version of the grails mail plugin, which works with DB driven mail configurations. It defaults to Config.groovy it it fails to fetch the MailConfig domain object based on the from address,\u00a0 which we usually in the sendMail() method. The plugin makes use of a customMailSender bean, which is actually a copy of the mailSender bean which gets built from Config.groovy, but can be modified in a thread safe environment with values fetched from the DB.<\/p>\n<p>The plugin is still in its infancy, but you can download the plugin and its source code <a href=\"https:\/\/github.com\/vivek-krishna\/grails-mail\" target=\"_blank\">here<\/a>. You can read the documentation <a href=\"https:\/\/github.com\/vivek-krishna\/grails-mail\/wiki\/Grails-DB-Driven-Mail-Plugin-Documentation\" target=\"_blank\">here.<\/a><\/p>\n<p>Hope you find this useful<\/p>\n<p>Vivek<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have been coming across a certain use case in a couple of projects that the Email credentials\/settings used for sending email should be different based on the from address. This is because the applications act as software services that are used by different organizations, which operate in the same business. And each needed their [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":5},"categories":[7],"tags":[4840,512,511,513,510,65],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/2719"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=2719"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/2719\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=2719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=2719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=2719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}