9 Replies Latest reply on Sep 20, 2005 11:31 AM by hannes

    JBoss Mail Services the appropriate thing? + newbie question

    hannes

      Hi there :)
      I am a student of business computing and I am currently working on a little "groupware" project. The heart is the workflow engine (JBoss jBPM) which assigns several tasks to different users (besides some automatic work). To start a specified workflow (process instance) I want to use the reception of a certain Email that contents some meta information (xml) as attachment. Furthermore I want to send mails to inform the user about new tasks.

      • Is the Mail-Service too complex for this? (Other possibilities?)
      • Could it be, that there is nearly no documention available? I downloaded jboss-mail-1.0-m2-final.zip and found only the http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossMailServer. No JavaDoc? No detailed description of the jboss-service.xml file?
      • When using the Mail-Service, I could create create a mail account for every user and use them for internal messages (like PM). Is there a web interface available for 1. Administrative purpose and 2. common user interaction? At best these things as (jsr168) portlets?
      • Currently, the users are in a 'StaticUserRepository' in the jboss-service.xml file. I'd like to user one common databased user management for all modules (jbpm, portal, mail ...) - how to configure JAAS for that purpose?

        Now some newbie-setting-up problems (base: jbpm-starter-kit-3.0.1 with AS 4.0.2):
        A have two users: user1 & user2 and Outlook as external Mailclient:
        I cant retrieve the mails - when I logon you can see following trace but nothing happens, so Outlook times out:
        10:35:33,592 INFO [Server] Got request
        10:35:33,592 INFO [Server] waiting for request
        10:35:33,602 WARN [CmdUSER] pop username set to user1
        10:35:33,602 INFO [STDOUT] socketOverride is null therefore I'm going to return false
        10:35:33,652 WARN [EntityFolder] folder requested for Entityfolder=user1
        10:35:33,662 INFO [STDOUT] socketOverride is null therefore I'm going to return false
        10:35:33,712 INFO [STDOUT] socketOverride is null therefore I'm going to return false
        10:35:33,762 INFO [STDOUT] socketOverride is null therefore I'm going to return false
        10:35:33,832 INFO [STDOUT] socketOverride is null therefore I'm going to return false

        Configured minimal without SSL and TLS. Sending email to an external address works perfectly. Imho the sysos are quite unpretty - how to change this? Is it worth having a look on more recent but beta builds of Mail-Services?

        Thank you for your helpd and I'm looking forward to reading your replies :)
        Regards
        Hannes


        • 1. Re: JBoss Mail Services the appropriate thing? + newbie ques
          hannes

          ok, found better infos in the http://wiki.jboss.org/wiki/Wiki.jsp?page=JBMSInstallingM3 - imho the wiki isn't really clearly created.

          • 2. Re: JBoss Mail Services the appropriate thing? + newbie ques
            acoliver

            I do not understand "imho the wiki isn't really clearly created" -- I think the wiki clearly was created and continues to exist :-)

            "To start a specified workflow (process instance) I want to use the reception of a certain Email that contents some meta information (xml) as attachment."

            This you could do with a mail listener or with a message driven bean. To do this with a mail listener take one of the exsting mail listeners (see $JBOSS_HOME/server/default/deploy/mail.ear/mail.sar/META_INF/jboss-service.xml for class names -- look to the MailListener chain service) and gut it with your own functionality and configure it to be the first mail listener in the chain.

            "
            When using the Mail-Service, I could create create a mail account for every user and use them for internal messages (like PM). Is there a web interface available for 1. Administrative purpose and 2. common user interaction? At best these things as (jsr168) portlets?
            "

            There will eventually be admin interfaces but there is not yet. It is unlikely that our admin interface will be a portlet. I was hoping to make it a plugin for the existing jboss-admin project but it seems to be targeted to jboss 5.0 and seems to be progressing more slowly than will be appropriate for us.

            "
            Currently, the users are in a 'StaticUserRepository' in the jboss-service.xml file. I'd like to user one common databased user management for all modules (jbpm, portal, mail ...) - how to configure JAAS for that purpose?
            "

            http://wiki.jboss.org/wiki/Wiki.jsp?page=HowToConfigureJBossMailServer1.0M3ToUseTheDatabaseServerLoginModule

            "
            A have two users: user1 & user2 and Outlook as external Mailclient:
            I cant retrieve the mails - when I logon you can see following trace but nothing happens, so Outlook times out:
            "

            I haven't been testing with outlook recently but others have and certainly with the M2 release. Without knowing what specific configuration setting you had, I can't tell you why this is happening. Perhaps if you describe your configuration here someone can help. For M4 I will try and put instructions on outlook if the screen capture works properly.

            "
            Configured minimal without SSL and TLS. Sending email to an external address works perfectly. Imho the sysos are quite unpretty - how to change this? Is it worth having a look on more recent but beta builds of Mail-Services?
            "

            Sysouts are removed in M3.

            -Andy

            • 3. Re: JBoss Mail Services the appropriate thing? + newbie ques
              hannes

              Thank you for your reply :)

              "acoliver@jboss.org" wrote:
              I do not understand "imho the wiki isn't really clearly created" -- I think the wiki clearly was created and continues to exist :-)

              You are right - at the very beginning I didn't looked in the M3 section - there are much more useful things to read :)
              So I totally changed to M3 and now everything is working fine :)
              "acoliver@jboss.org" wrote:
              This you could do with a mail listener or with a message driven bean. To do this with a mail listener take one of the exsting mail listeners (see $JBOSS_HOME/server/default/deploy/mail.ear/mail.sar/META_INF/jboss-service.xml for class names -- look to the MailListener chain service) and gut it with your own functionality and configure it to be the first mail listener in the chain.

              Sounds interesting - I will figure that out.

              little OT:
              I have some lacks in networking. Internal mailing (user1 <> user2) and outgoing intranet mailing (userX -> intranet) is working perfectly, but how can I send a mail from Outlook via MS Exchange to my little jBoss MS without bothering the net admins? Maybe with a special domain name? user1@jboss-server-ip isn't working - imho the domain information is missing. The internet is also not reachable - most possible a firewall issue - but that's not important.

              Regards
              Hannes

              • 4. Re: JBoss Mail Services the appropriate thing? + newbie ques
                acoliver

                "
                You are right - at the very beginning I didn't looked in the M3 section - there are much more useful things to read :)
                So I totally changed to M3 and now everything is working fine :)
                "

                Ahh yes do note that I regard documentation to develop with milestones (I do documentation concurrently but mostly at the end of each release) so the M3 docs will be the basis for M4 but we'll have a little more doco for each release. M4 unfortunately won't add a lot because there are a lot of changes so I'll spend a good deal of time just updating, but will of course try and cover new features.

                "
                I have some lacks in networking. Internal mailing (user1 <> user2)
                "

                You can probably just do "localhost". Set "localhost" "localhost.localdomain" and "localdomain" as your domains in your "domain group" on the install screen. Set the host name as "localhost.localdomain".

                What cannot yet be done is to get JBMS to route ALL mail or mail to particular domains independent of DNS lookup (meaning send all mails to @jboss.org to mailrouter.foobar.com) but I have spec'd that out in JIRA for an M4 or M5 feature. (we're behind so I may push it to M5 depending). It should be simple to get OUTLOOK to do this however if you say @localhost. Alternatively (and I don't have a windows box in front of me so this is off the cuff from memory), you can edit c:\windows\system32\drivers\etc and add an entry (ip hostname alias). then import it.

                http://support.microsoft.com/?kbid=105997
                http://accs-net.com/hosts/how_to_use_hosts.html

                • 5. Re: JBoss Mail Services the appropriate thing? + newbie ques
                  hannes

                   

                  "acoliver@jboss.org" wrote:
                  You can probably just do "localhost". Set "localhost" "localhost.localdomain" and "localdomain" as your domains in your "domain group" on the install screen. Set the host name as "localhost.localdomain".

                  don't work

                  I build my own MailListenerer and it is working fine :) But, is there really no JavaDoc for the API available? Especially such central classes like org.jboss.mail.message.Mail are not totally clear for me - e.g. I want to get the attachment of a mail, but I don't know how.

                  Regards

                  • 6. Re: JBoss Mail Services the appropriate thing? + newbie ques
                    hannes

                    ok, one more try:
                    The http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailUsage -API provides everything I need, but in my MailListener, there is only a org.jboss.mail.message.Message object or, like in the examples, casted in a org.jboss.mail.message.Mail object. How can I get the Attachmentstream anyway?

                    • 7. Re: JBoss Mail Services the appropriate thing? + newbie ques

                       

                      Mail mail = (Mail) message;
                      MailBody body = mail.getMailBody();
                      InputStream in = body.getInputStream();


                      We currently don't parse the mail body. You will all of bytes of the email as a stream.

                      It's worth noting that we are is the process of rewriting the message structure. We don't use JavaMail to store our messages.

                      Have you tried 'build javadoc' to build the javadoc for the mail server. You will need the source to do this.

                      Mike.

                      • 8. Re: JBoss Mail Services the appropriate thing? + newbie ques
                        hannes

                         

                        "mikezzz" wrote:
                        We currently don't parse the mail body. You will all of bytes of the email as a stream.

                        Oh no, I am not familiar with the MIME stuff: is there any helper-functions available? Or does the possibility exist converting the jbmail into a javamail?
                        Throwing a look on the body:
                        (...) html part
                        15:01:37,875 INFO [ChangeRequestListener]
                        15:01:37,875 INFO [ChangeRequestListener] ------=_NextPart_001_000E_01C5BDF4.32F89930--
                        15:01:37,875 INFO [ChangeRequestListener]
                        15:01:37,875 INFO [ChangeRequestListener] ------=_NextPart_000_000D_01C5BDF4.32F40550
                        15:01:37,875 INFO [ChangeRequestListener] Content-Type: text/plain;
                        15:01:37,875 INFO [ChangeRequestListener] name="test.xml"
                        15:01:37,875 INFO [ChangeRequestListener] Content-Transfer-Encoding: quoted-printable
                        15:01:37,875 INFO [ChangeRequestListener] Content-Disposition: attachment;
                        15:01:37,875 INFO [ChangeRequestListener] filename="test.xml"
                        15:01:37,875 INFO [ChangeRequestListener]
                        15:01:37,875 INFO [ChangeRequestListener] <?xml version=3D"1.0" encoding=3D"utf-8"?>
                        (...) the rest of the xml file
                        15:01:37,885 INFO [ChangeRequestListener] ------=_NextPart_000_000D_01C5BDF4.32F40550--
                        15:01:37,885 INFO [ChangeRequestListener]


                        So the attachment is between the ' ------=_NextPart' Lines - but I have to handle html-mails either, so I have to distingusih that.
                        The html-part starts with:
                        15:01:37,825 INFO [ChangeRequestListener] ------=_NextPart_001_000E_01C5BDF4.32F89930
                        15:01:37,825 INFO [ChangeRequestListener] Content-Type: text/html;
                        15:01:37,825 INFO [ChangeRequestListener] charset="iso-8859-1"
                        15:01:37,825 INFO [ChangeRequestListener] Content-Transfer-Encoding: quoted-printable


                        Honestly, I don't want spending too much time for this issue. it would be nice if someone may tell me where to find parsing-helpers.

                        • 9. Re: JBoss Mail Services the appropriate thing? + newbie ques
                          hannes

                          Ok, found a solution:

                          Properties props = new Properties();
                           props.put("mail.smtp.host", "localhost");
                           Session ses = Session.getInstance(props, null);
                           javax.mail.Message mimeMsg = new MimeMessage(ses, mail.getRawStream());
                          
                           Multipart mp = (Multipart) mimeMsg.getContent();
                           for (int i = 0, n = mp.getCount(); i < n; i++) {
                           log.info("---------------part " + i);
                           Part part = mp.getBodyPart(i);
                           String disposition = part.getDisposition();
                           log.info("disposition: " + disposition);
                           log.info("contentType: " + part.getContentType());
                          
                           if ((disposition != null)
                           && ((disposition.equals(Part.ATTACHMENT) || (disposition
                           .equals(Part.INLINE))))) {
                           log.info("filename: " + part.getFileName());
                           }
                          
                           }