I guess this is not a specific question, but getting ideas on how to.
We have a Flex - Spring - JMS - Hibernate webapp. Our requirement is to send automatic emails when some event occurs (new user registered, user performed an import successfully). We will have the Email addressess, content, Subject, etc in the DB. We can have the Mail Server settings hardcoded (or in the db). I would like to have this as a separate service for reusabulity. I would like to get your inputs on how to achieve this and also provide some optimal solutions on what would be the best way. Do I use JMS for this or Spring's Java Mail Sender. Which is more efficient and the latest.
Hope my question isn't too vague. Your inputs are appreciated as always :)
Thanks
Harry
Here are few low-hanging choices you have (from best to worst):
Spring Email support
This is the simplest approach (not counting coding to raw JavaMail API). If you need to just send that e-mail, you don't need nothing more. You can esaily inject
JavaMailSender
wherever you need it.Email support in spring-integration
This solutions is built on top of 1. If you need a reusable service with enterprise integration patterns bundled (like filtering, routing, enhancing, etc.) and great flexibility. If your application does a lot of integration, this might be a smart choice but is a bit more heavyweight when it comes to maintenance.
SMTPAppender
in logbackThis Logback appender is typically used to send an e-mail yo support/administrator when an ERROR occurs, containing error event itself and few previous events. But with a little bit of configuration you can easily use to it catch specific events in your application (triggered by logging statements) and send messages. However it will be a bit cumbersome and not flexible enough.