5 Replies Latest reply: Apr 18, 2012 10:33 AM by Cody Lerum RSS

Seam mail - unable to configure smtp server

Ryan Carlson Newbie

I'm trying to configure Seam mail to do email templating and sending for a project and I'm stuck trying to get configure seam/jboss to use our smtp server.  I'm using jboss 7.1.1.FINAL and using seam mail 3.1.0.Beta4.  Other dependencies are listed in pom.xml file snippet below.  I didn't include the full file, just seam/mail dependencies.  If it would be helpful to see more, let me know.

 

What I'm seeing is that it's always trying to find an smtp server on localhost (port 25) instead of the values I'm setting in both beans.xml and standalone-full.xml.  Thus when I get to m.send() I get an exception.. Connection refused.  Stacktrace is attached.  When I step through in debug mode, I see the property: mail.smtp.host=localhost .  Am I not setting this in the correct location, or are there possibly dependencies missing in my pom?

 

I didn't find any examples to go from online, so any help here would be most appreciated!  Thanks!

code

@Inject private Instance<MailMessage> message;

 

    public String submitRequest() throws Exception{

        try{

            VelocityTemplate vt = new VelocityTemplate(new FileInputStream("/Applications/jboss-7.1.1/standalone/deployments/helpdesk-ee6.war/resources/email/emailTemplate.vm"));

            String str = vt.merge(new HashMap<String,Object>());

 

            MailMessage m = message.get();

            m.to(new InternetAddress("ryan dot t dot carlson at myorg dot org,"Ryan T. Carlson"))

            .from(new InternetAddress("ryan dot t dot carlson at myorg dot org,"Ryan T. Carlson""))

            .subject("None")

            .bodyHtml(str)

            .send();

        }

        catch(FileNotFoundException fnfe){

            fnfe.printStackTrace();

        }

        return "foo";

    }

beans.xml

<beans xmlns="http://java.sun.com/xml/ns/javaee"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:s="urn:java:ee"

       xmlns:mail="urn:java:org.jboss.seam.mail.core"

       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd">

 

    <mail:MailConfig serverHost="smtp1.myorg.org" serverPort="25">

        <s:modifies/>

    </mail:MailConfig>

 

</beans>

pom.xml

<dependencies>

...

<dependency>

         <groupId>javax.activation</groupId>

         <artifactId>activation</artifactId>

    </dependency>

 

    <dependency>

         <groupId>javax.mail</groupId>

         <artifactId>mail</artifactId>

     </dependency>

 

    <dependency>

        <groupId>org.jboss.seam.mail</groupId>

        <artifactId>seam-mail-velocity-impl</artifactId>

        <version>3.1.0-SNAPSHOT</version>

    </dependency>

 

    <dependency>

        <groupId>org.apache.velocity</groupId>

        <artifactId>velocity</artifactId>

        <version>1.7</version>

    </dependency>

 

    <dependency>

        <groupId>org.jboss.seam.mail</groupId>

        <artifactId>seam-mail</artifactId>

        <version>3.1.0.Beta4</version>

    </dependency>

</dependencies>

 

standalone-full.xml

<subsystem xmlns="urn:jboss:domain:mail:1.0">

     <mail-session jndi-name="java:Mail">

          <smtp-server outbound-socket-binding-ref="mail-smtp"/>

     </mail-session>

</subsystem>

......

<outbound-socket-binding name="mail-smtp">

     <remote-destination host="smtp1.myorg.org" port="25"/>

</outbound-socket-binding>

 

Message was edited by: Ryan Carlson -cleaned up email addresses in code snippet