5 Replies Latest reply on Aug 3, 2012 4:57 AM by michal.warecki

    routing mail with camel

    mathieuj

      hello,

       

      i'm using fuse esb 4.4.1.

       

      i would like to do a simple work for send something by mail .

       

      my bundle is correclty started but my probleme come from my endpoint.

       

      this is my class:

       

      public static void main(String[] args) throws Exception {

       

          public void configure() {

       

              AppCamelContext.getInstance().setApplicationContext(getContext());

               

              from("timer:myTimerEvent?fixedRate=true&delay=0&period=1000")

              .setBody(constant("Salut    "))

               .to("smtp://smtp.gmail.com:587?password=XXX&username=myadress@gmail.com");                       

                 }

                                

               });

       

       

      if someone has an idea to resolve that.

       

      thank you

       

      Mathieu

        • 1. Re: routing mail with camel
          michal.warecki

          What are the exceptions you get and which version of jdk do you use?

          • 2. Re: routing mail with camel
            mathieuj

            i just get this error in my log:

             

            java.net.UnknownHostException: smtp.gmail.com. Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;

             

             

            my jdk is 1.6

             

            mathieu

            • 3. Re: routing mail with camel
              michal.warecki

              Are you under a proxy?

              • 4. Re: routing mail with camel
                mathieuj

                yes, it could be the problem,

                 

                but i don't know how to configure it..

                • 5. Re: routing mail with camel
                  michal.warecki

                  Generally I think Java Mail API doesn't work with web proxy:

                   

                  Q: How do I configure JavaMail to work through my proxy server? updated!

                  A: JavaMail does not currently support accessing mail servers through a web proxy server. One of the major reasons for using a proxy server is to allow HTTP requests from within a corporate network to pass through a corporate firewall. The firewall will typically block most access to the Internet, but will allow requests from the proxy server to pass through. In addition, a mail server inside the corporate network will perform a similar function for email, accepting messages via SMTP and forwarding them to their ultimate destination on the Internet, and accepting incoming messages and sending them to the appropriate internal mail server.

                   

                  If your proxy server supports the SOCKS V4 or V5 protocol (http://www.socks.nec.com/aboutsocks.html, RFC1928) and allows anonymous connections, and you're using JDK 1.5 or newer and JavaMail 1.4.5 or newer, you can configure a SOCKS proxy on a per-session, per-protocol basis by setting the "mail.smtp.socks.host" property as described in the javadocs for the com.sun.mail.smtp package. Similar properties exist for the "imap" and "pop3" protocols.

                   

                  If you're using older versions of the JDK or JavaMail, you can tell the Java runtime to direct all TCP socket connections to the SOCKS server. See the Networking Properties guide for the latest documentation of the socksProxyHost and socksProxyPort properties. These are system-level properties, not JavaMail session properties. They can be set from the command line when the application is invoked, for example: java -DsocksProxyHost=myproxy .... This facility can be used to direct the SMTP, IMAP, and POP3 communication from JavaMail to the SOCKS proxy server. Note that setting these properties directs all TCP sockets to the SOCKS proxy, which may have negative impact on other aspects of your application.

                   

                  Without such a SOCKS server, if you want to use JavaMail to directly access mail servers outside the firewall, the firewall will need to be configured to allow such access. JavaMail does not support access through a HTTP proxy web server.

                   

                   

                  You may also try to use tunneling but I'm not an expert in such configuration.

                  Check this: http://stackoverflow.com/questions/10085856/java-mail-exception-error