4 Replies Latest reply on Sep 29, 2009 5:06 AM by kapitanpetko

    Perform action after email is sent

    jfaath

      I'm sending an email asynchronously to a group of people using the Seam mail functionality.  However, I have a requirement that the content of the email needs to be stored in the database, presumably right after the email is sent.


      Is there any way to hook into the method that sends the email?  Is there an event that fires after an email is successfully sent?  Any ideas on how this might be done?


      -JF

        • 1. Re: Perform action after email is sent
          kapitanpetko

          Jeff Faath wrote on Sep 24, 2009 20:38:


          Is there any way to hook into the method that sends the email?  Is there an event that fires after an email is successfully sent?  Any ideas on how this might be done?


          Not really, and there are no events. You could do two things:



          1. use JavaMail directly (do not use Seam mail)

          2. write and install your own javax.mail.Transport that stores the mail before sending it. Look at Seam's MockTransport for ideas.



          HTH

          • 2. Re: Perform action after email is sent
            jfaath

            Thanks, I'll give #2 a shot.  I don't want to give up on the great templating functionality that Seam mail provides.

            • 3. Re: Perform action after email is sent
              jfaath

              Nickolay,


              Quick question regarding option two.  Is there an example of how install my own transport?  The api doc for MockTransport says to set the session transport property to mock.  From what I've read about JavaMail, I need to add my transport to the provider registry.  Is this done with MockTransport and if so, is there a code example floating around in the distribution?


              Thanks,


              -JF

              • 4. Re: Perform action after email is sent
                kapitanpetko

                The details about how to install a transport are somewhere in the JavaMail API reference, most probably
                the Session class. Also look at JavaMail. IIRC, you need to put a
                javamail.providers property file in your META-INF.


                As for MockTransport, search for javamail.providers in the Seam source, should be somewhere there.


                HTH