4 Replies Latest reply on Mar 28, 2008 4:48 PM by pmuir

    Retrieve rendered mail content

      Hi,


      I use renderer.render(/my/mail.xhtml) quite often and am very satisfied with this approach of sending mail. Now I'd like to retrieve the full raw rendered mail body (including headers etc.). How is this achieved?


      Cheers

        • 1. Re: Retrieve rendered mail content
          nickarls

          Well, you could set mailsession debug to true and the mail might end up somewhere in a log or you might add a debug-mailbox to the cc-list but I think it might be a little hard to intercept programmatically in realtime.


          Of course, if you are OK with modified Seam code it should be pretty easy to add an observer that passes you the mail right before it is sent.

          • 2. Re: Retrieve rendered mail content
            pmuir

            Create a new mail transport that you control the endpoint of (see for example org.jboss.seam.mock.MockTransport), register it in /META-INF/javamail.providers, and tell the MailSession to use it by calling MailSession.instance().setTransport(name);

            • 3. Re: Retrieve rendered mail content

              Worked like a charm, except for 'MailSession.instance().setTransport(name)', since 'transport' only  is gettable and needs to be set in components.xml. (There is some info about that in MockTransport.java)


              I'll subtract 1 star due to that misinformation ;-)

              • 4. Re: Retrieve rendered mail content
                pmuir

                Oh yeah, as MailSession is @Unwrap ;-)