title: can't connect to smtp server in development environment
body: <p>so here's the problem I'm having:</p>
  
  <p>When I'm trying to connect to an smtp sever, and when I try it in netbeans, it gives me an error saying I can't connect:</p>
  
  <p>I know that my computer can connect to the mail server, since telnet works perfectly fine when I try it, which makes me think the issue is with the code.</p>
  
  <p>However when the program I wrote is used on a different computer, it works just fine. According to wireshark, the program never tried to connect to the mail server.</p>
  
  <p>I've tried making myself an administrator on the firewall, and that has no affect on the program.</p>
  
  <p>here's the code I'm using:</p>
  
  <pre><code>private static final Properties SYS_PROPS = System.getProperties();
  
  public void sendEmail(String user, String Message, String subject, String recipient) throws ResourceException {
       try {
          //Set the host property
          SYS_PROPS.setProperty("mail.smtp.host", "host");
  
          System.setProperty("java.net.preferIPv4Stack" , "true");
  
          //Create a session for all the emails
          Session session = Session.getDefaultInstance(SYS_PROPS);
          //Get the name of the contact peep
          String name = user;
  
              //Create a new message
              MimeMessage message = new MimeMessage(session);
              MimeMultipart multiPart = new MimeMultipart();
  
              //Set to, from, and subject
              message.setFrom(new InternetAddress("http://localhost:8084/appName"));
              message.addRecipient(RecipientType.TO, new InternetAddress(recipient));
              message.setSubject(subject);
  
              //Next, add the message part
              BodyPart arm = new MimeBodyPart();
  
              arm.setContent(Message, "text/html");
              multiPart.addBodyPart(arm);
  
              //Set the multipart to the message
              message.setContent(multiPart);
  
              //Send the message
              Transport.send(message);
  
      } catch (MessagingException ex) {
          log(ex);
      }
  }
  </code></pre>
  
  <p>My current theory is that I somehow have to configure netbeans, or tomcat, to allow me to send mail.</p>
  
  <p>I would really appreciate any help that you can give!</p>
  
  <p>I'm getting this error when I use the program:</p>
  
  <pre><code>SEVERE: null
  com.sun.mail.util.MailConnectException: Couldn't connect to host, port: 10.1.0.5, 25; timeout -1;
    nested exception is:
      java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1984)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:656)
      at javax.mail.Service.connect(Service.java:345)
      at javax.mail.Service.connect(Service.java:226)
      at javax.mail.Service.connect(Service.java:175)
      at javax.mail.Transport.send0(Transport.java:253)
      at javax.mail.Transport.send(Transport.java:124)
      at com.echoman.saasadmin.dao.EmailDao.sendEmail(EmailDao.java:347)
      at com.echoman.saasadmin.services.TenantService.SendEmail(TenantService.java:229)
      at com.echoman.saasadmin.form.EmailForm$2.buttonClick(EmailForm.java:148)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
      at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
      at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
      at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:979)
      at com.vaadin.ui.Button.fireClick(Button.java:393)
      at com.vaadin.ui.Button$1.click(Button.java:57)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
      at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
      at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:287)
      at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:180)
      at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:93)
      at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
      at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1402)
      at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:579)
      at java.net.Socket.connect(Socket.java:528)
      at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:301)
      at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:229)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1950)
      ... 52 more
  </code></pre>
  
  <p>this is my IP config</p>
  
  <pre><code>Ethernet adapter Local Area Connection
  Media State:Media Disconnected
  Connection-Specic DNS Suffix:
  
  
  Ethernet adapter Ethernet:
  Connection-specific DNS Suffix :echoman.local
  Ipv4 Address :10.1.2.15
  Subnet mask :255.255.252.0
  Default GateWay :10.1.0.5
  </code></pre>