0 Replies Latest reply on Sep 22, 2015 8:25 AM by nans james

    Jboss 7 configuration with apache james 2.3 to send mail to external mail server like gmail,yahoo...

    nans james Newbie

      I am trying to send mail from my localhost mail server to external mail server with the help of jboss 7 and apache james mail server.

      I have modified the standalone-full.xml as below:


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

              <mail-session jndi-name="java:jboss/mail/Default">

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

                                <login name="nansjames" password="password"/>



              <mail-session jndi-name="baseModule/EmailNotification"  from="emailaddress.com">

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

                              <login name="user" password="password" />


                        <pop3-server outbound-socket-binding-ref="mail-pop3">

                               <login name="user" password="password" />





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

                  <remote-destination host="remotehost" port="25"/>



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

                  <remote-destination host="remotehost" port="25"/>


      In config.xml in Apache James 2.3


      <processor name="transport">

      <mailet match="All" class="RemoteDelivery">

           <gateway> smtp.gmail.com </gateway>







      Started telnet localhost 4555 and added the users..


      Java program:


      public class SendNewMail extends HttpServlet



          private Session mailSession;


      // Get system properties

          Properties properties = System.getProperties();



          //SmtpAuthenticator authentication = new SmtpAuthenticator();

          //Session session = Session.getDefaultInstance(properties,authentication);

          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {



                  PrintWriter out=response.getWriter();

                  try    {

                      MimeMessage m = new MimeMessage(mailSession);

                      Address from = new InternetAddress("nansjames");

                      Address[] to = new InternetAddress[] {new InternetAddress("mygmailaccount@gmail.com") };



                      m.setRecipients(Message.RecipientType.TO, to);

                      m.setSubject("JBoss AS 7 Mail");

                      m.setSentDate(new java.util.Date());

                      m.setContent("Mail sent from JBoss AS 7","text/plain");


                      out.println("Mail sent!");


                  catch (javax.mail.MessagingException e)



                      out.println("Error in Sending Mail: "+e);






      I am received "Mail sent"message in the server but no mail is sending to the gmail account.


      Please help where i have done the mistake and what other changes i have to made. Do i need to enter domain name in domainlist but which is available in apache-james-3.0 beta 4.

      Thanks in advance.Can anyone reply for this question?