3 Replies Latest reply on Sep 3, 2008 2:44 PM by Pete Muir

    Sending HTML Mails fails...

    Jan Groth Novice

      Hello,


      I'm struggling to send an email in HTML. All I receive is a flat file, which is free of all html-tags (read: formattings) :-(


      Basically I'm using the standard example, and I don't see what I'm doing wrong. Maybe someone else does?


      Many thanks,
      Jan


      <m:message xmlns="http://www.w3.org/1999/xhtml"
           xmlns:m="http://jboss.com/products/seam/mail"
           xmlns:h="http://java.sun.com/jsf/html">
      
           <m:from name="noreply" address="xxx@yyy.de" />
           <m:to name="#{userToActivate.firstName} #{userToActivate.lastName}" >xxx@yyy.de</m:to>
           <m:subject>Aktivierungsemail</m:subject>
      
           <m:body >
                <html>
                     <head>
                     </head>
                     <body>          
                          Lieber #{authenticator.userToActivate.firstName} #{authenticator.userToActivate.lastName}!
                          <br/><br/>
                          <br/><br/>
                          
                          Wir begrüßen Sie herzlich auf unserem Portal!<br/><br/>
                          
                          Um Ihren Zugang endgültig freizuschalten, folgen Sie bitte in den nächsten 2 Stunden dem unten stehenden Link zur Aktivierung Ihres Accounts. 
                          <br/><br />
                        <a href="/internet/expirytoken/splash.seam?secretId=#{authenticator.expiryToken.secret}">
                             www.xxx.yy/internet/expirytoken/splash.seam?secretId=#{authenticator.expiryToken.secret}
                        </a>
                          <br/><br />
                          Hinweis: Sie können den Link auch aus der Mail herauskopieren und in die Adresszeile Ihres Internet-Browsers einfügen.
                          <br/><br/>
                          <br/><br/>
                          Viele Grüße,
                          <br/><br/>
                          Ihre Team
                     </body>
                </html>
           </m:body>
      </m:message>




      What I get is like this:


      
                
                     
                     
                               
                          Lieber Max Mustermann!
                          
                          
                          
                          ----
                               
                          Wir begrüßen Sie herzlich auf unserem Portal!
                          
                          Um Ihren Zugang endgültig freizuschalten, folgen Sie bitte in den nächsten 2 Stunden dem unten stehenden Link zur Aktivierung Ihres Accounts. 
                          
                        
                             www.xxx.yy/internet/expirytoken/splash.seam?secretId=12wZJ2G0r43XVu23sfo1ZwYGdfCw3jWcmKo7kuN5Pk1
                        
                          
                          Hinweis: Sie können den Link auch aus der Mail herauskopieren und in die Adresszeile Ihres Internet-Browsers einfügen.
                          
                          
                          Viele Grüße,
                          
                          Ihre Team
                     
                
      


        • 1. Re: Sending HTML Mails fails...
          Jan Groth Novice

          What i should have pointed out is that the second snipped is from the source-view in my mail-client (outlook 2007). the mail itself is rendered without any linebreaks...


          jan

          • 2. Re: Sending HTML Mails fails...
            Jan Groth Novice

            allright, I found the solution. wonder if it's a bug or a feature.


            when is test mail sending through testNG (1), all html will be ignored. when I test through the regular web-frontend (2), the mail gets sent and the html is in the mail-source.


            furthermore i need some server parameters from the HttpServletRequest. i discovered that


            HttpServletRequest request = (HttpServletRequest)FacesContext.
            getCurrentInstance().getExternalContext().getRequest();




            returns null in (1) and the valid request in (2).


            My test are created like this:


                      return new FacesRequest(viewId, cid) {
            
                           @Override
                           protected void updateModelValues() throws Exception {
                                setValue("#{customer.user.gender}", USER_GENDER);
                                setValue("#{customer.user.firstName}", USER_FIRSTNAME);
                                setValue("#{customer.user.lastName}", USER_LASTNAME);
                                setValue("#{customer.user.loginName}", USER_LOGINNAME);
                                setValue("#{customer.user.password}", USER_PASSWORD);
                                setValue("#{registrationController.passwordVerify}", USER_PASSWORD);
                                setValue("#{registrationController.agbConfirm}", USER_AGB);
            
                                assert isLongRunningConversation();
                           }
            
                           /*
                            * Schreiben der Werte in die DB
                            */
                           @Override
                           protected void invokeApplication() throws Exception {
                                invokeAction("#{registrationController.registerCustomer}");
                           }
                      };
            



            where registerController.registerCustomer will send the mail.


            bug or feature?


            jan

            • 3. Re: Sending HTML Mails fails...
              Pete Muir Master

              Sending mail through SeamTest isn't supported.