0
votes

I've developed a web application (JSF, Spring, jboss AS 7.0.13) for sending mails over smtp using Javamail 1.4 and Domino Lotus 9.0.1 as an Mailing Server.

What's already done :

  • Domino Lotus is already configured to allow smtp messages.
  • I can send mails using Lotus Notes (Mailing client).
  • I can send mails using simple clients (simple jar files that i've developed for testing purpose).

Send method source code :

    System.out.println(" ******************* START SENDING EMAIL ***********************");

    Properties props = new Properties();

    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(true);

    props.put("mail.smtp.host", "192.168.25.5");
    props.put("mail.smtp.socketFactory.port","25");

    props.put("mail.smtp.port", "25");

    session = Session.getInstance(props); 

    try {
        Message message;
        message = new MimeMessage(session);
        message.setFrom(new InternetAddress("[email protected]"));
        message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse("[email protected]"));

        message.setSubject("Test Notification");
        message.setContent("Hello there !!", "text/html");

        Transport.send(message);


    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }


    System.out.println(" ******************* END SENDING MAIL ***********************");
}

What's strange Using the same method in a simple java application i can send mails without a problem but,When trying to send mails from my web application, and of course using the same method source code again >>> i got the exception :

Caused by: javax.mail.MessagingException: Could not connect to SMTP host: 192.168.25.5, port: 25; nested exception is: java.net.SocketException: Unrecognized Windows Sockets error: 10107: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934) [mail-1.4.4.jar:1.4.4] at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) [mail-1.4.4.jar:1.4.4] at javax.mail.Service.connect(Service.java:295) [mail-1.4.4.jar:1.4.4] at javax.mail.Service.connect(Service.java:176) [mail-1.4.4.jar:1.4.4] at javax.mail.Service.connect(Service.java:125) [mail-1.4.4.jar:1.4.4] at javax.mail.Transport.send0(Transport.java:194) [mail-1.4.4.jar:1.4.4] at javax.mail.Transport.send(Transport.java:124) [mail-1.4.4.jar:1.4.4] ... 83 more Caused by: java.net.SocketException: Unrecognized Windows Sockets error: 10107: connect at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) [rt.jar:1.7.0_55] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) [rt.jar:1.7.0_55] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) [rt.jar:1.7.0_55] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) [rt.jar:1.7.0_55] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) [rt.jar:1.7.0_55] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) [rt.jar:1.7.0_55] at java.net.Socket.connect(Socket.java:579) [rt.jar:1.7.0_55] at java.net.Socket.connect(Socket.java:528) [rt.jar:1.7.0_55] at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288) [mail-1.4.4.jar:1.4.4] at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231) [mail-1.4.4.jar:1.4.4] at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900) [mail-1.4.4.jar:1.4.4] ... 89 more

Other infos :

  • Domino Lotus Server ip_adress : 192.168.25.5
  • Domino Lotus smtp default port : 25
  • Alice and Bon mails adresses already created.
1
Are you running your test applications on the same machine that runs the web application server?RealSkeptic
yes, they're running on the same serverM3d3L0
In which context does your web application run? I think, that the process it runs in does not have permission to use ports. A program that is called manually has your user rights and therefor usually is allowed to use the ports, a service using system account for example might be not allowed.Torsten Link
i'm running my application using a service that i've created for jboss, what do you propose ? running jboss manually (using standalone.bat)M3d3L0
normally the system account is a high previleged account, it should already has the permissions to use ports.M3d3L0

1 Answers

0
votes

Thanks Torsten Link, you're right the jboss service had not all the permission to allow the web application communicate over smtp with Domino Lotus, running jboss manually through standalone.bat solved the problem. Thanks again =)