1 Reply Latest reply on Feb 26, 2006 4:52 AM by Günter Merl

    jakarta mailer-taglib in JBoss Portal 2.2.1RC2

    Günter Merl Newbie

      Hello

      I have a problem with the Mailer1.1 Taglib from the Jakarta project. I want to use it in a jsf- portlet, but no mail is sent. I have no errors in the JBoss-logs and no exception is thrown. If I deploy the war without portlet specific descriptors to Tomcat 5.5.15 with MyFaces, everything works, in JBoss 4.0.3SP1 I can see the index.jsp with the values of the JNDI-Lookup and the mail.jsp with the values of the backingbean, but no mail. I've tried to solve the problem for one week, now I don't have any ideas left. Perhaps someone in this forum can help me. Perhaps its a problem with my descriptors, because there are even no logs in my Mailserver, so I think, there is no connection from JBoss to my Postfix

      index.jsp

      ...
      <%-- only for testing purposes
      <%
       javax.naming.InitialContext jndiContext = new javax.naming.InitialContext();
       javax.mail.Session mailSession = (javax.mail.Session)jndiContext.lookup("java:/comp/env/mail/ContactSession");
       String host = mailSession.getProperty("mail.smtp.host");
      %>
      --%>
      <f:loadBundle basename="contact.bundle.Messages" var="messages" />
      <f:view>
       <%= host %>
       <h:form id="contactform">
       <h:panelGrid align="center" width="75%" columns="2" headerClass="portlet-table-header" rowClasses="portlet-table-body, portlet-table-alternate" footerClass="portlet-table-footer">
       <f:facet name="header">
       <h:outputText value="#{messages.fillLabel}" style="portlet-section-header" />
       </f:facet>
       <h:outputLabel value="#{messages.firstNameLabel}" for="firstName" style="portlet-form-field-label" />
       <h:inputText id="firstName" value="#{messageHandler.firstName}" required="true" style="portlet-form-input-field" />
       <f:facet name="footer">
       <h:panelGroup>
       <h:commandButton id="sendbutton" type="submit" action="send" value="#{messages.sendButtonLabel}" style="portlet-form-button" /><h:commandButton type="reset" value="#{messages.resetButtonLabel}" style="portlet-form-button" />
       </h:panelGroup>
       </f:facet>
       </h:panelGrid>
       </h:form>
      </f:view>
      ...
      


      mail.jsp
      ...
      <%@taglib prefix="mailer" uri="http://jakarta.apache.org/taglibs/mailer-1.1"%>
      <f:loadBundle basename="contact.bundle.Messages" var="messages" />
      <f:view>
      <mailer:mail session="java:/comp/env/mail/ContactSession" from="info@test.com" replyTo="info@test.com">
       <mailer:setrecipient type="to"><h:outputText value="#{messageHandler.from}" /></mailer:setrecipient>
       <mailer:subject><h:outputText value="#{messages.autoResponderHeading}" /></mailer:subject>
       <mailer:message type="text">
       <h:outputText value="#{messages.autoResponderHeading}" />
       </mailer:message>
       <mailer:message type="html">
       <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
       <html>
       <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title><h:outputText value="#{messages.autoResponderHeading}" /></title>
       </head>
       <body>
       <h1><h:outputText value="#{messages.autoResponderHeading}" /></h1>
       <p><h:outputText value="#{messages.autoResponderBody}" /></p>
       </body>
       </html>
       </mailer:message>
       <mailer:send />
      </mailer:mail>
      ...
      


      web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <resource-ref>
       <description>JNDI javax.mail.Session for contact form</description>
       <res-ref-name>mail/ContactSession</res-ref-name>
       <res-type>javax.mail.Session</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
       </resource-ref>
      
      </web-app>


      jboss-web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
       <security-domain flushOnSessionInvalidation="false"/>
       <context-root>/portal-contact</context-root>
       <resource-ref>
       <description>Shit happens</description>
       <res-ref-name>mail/ContactSession</res-ref-name>
       <res-type>javax.mail.session</res-type>
       <jndi-name>java:/mail/ContactSession</jndi-name>
       </resource-ref>
      </jboss-web>


      deploy/portal-contact-mail-service.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE server>
      <server>
       <mbean code="org.jboss.mail.MailService"
       name="jboss:service=mail/ContactSession">
       <attribute name="JNDIName">java:/mail/ContactSession</attribute>
       <attribute name="User">xxx</attribute>
       <attribute name="Password">xxx</attribute>
       <attribute name="Configuration">
       <configuration>
       <property name="mail.transport.protocol" value="smtp"/>
       <property name="mail.store.protocol" value="imap"/>
       <property name="mail.smtp.auth" value="true"/>
       <property name="mail.smtp.host" value="test.com"/>
       <property name="mail.imap.host" value="test.com"/>
       <property name="mail.user" value="xxx"/>
       <property name="mail.smtp.user" value="xxx"/>
       <property name="mail.smtp.password" value="xxx"/>
       <property name="mail.debug" value="true"/>
       </configuration>
       <depends>jboss:service=Naming</depends>
       </attribute>
       </mbean>
      
      </server>
      


      Thanks in advance
      zehner