Error sending email

We have recently upgraded our gateway machine and have had all our automatic emails stop working. When I try to execute the following code, where smtpAddress is the address of the SMTP server as a string and fromAddr is the address of the client sending the message as a string:, fromAddr, "Subject - Test", "Hello", 0, [value], [], [], timeout)

I’m getting the following error on the gateway log:

3:45:34 PM Gateway ERROR(500): Error sending email.

javax.mail.MessagingException: Could not connect to SMTP host: smtpAddress, port: 25;
nested exception is: Network is unreachable: connect
at com.sun.mail.smtp.SMTPTransport.openServer(
at com.sun.mail.smtp.SMTPTransport.protocolConnect(
at javax.mail.Service.connect(
at javax.mail.Service.connect(
at javax.mail.Service.connect(
at javax.mail.Transport.send0(
at javax.mail.Transport.send(
at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.sendEmail(
at com.inductiveautomation.ignition.gateway.servlets.Gateway._sendEmail(
at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(
at org.eclipse.jetty.servlet.ServletHolder.handle(
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.session.SessionHandler.doHandle(
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
at org.eclipse.jetty.servlet.ServletHandler.doScope(
at org.eclipse.jetty.server.session.SessionHandler.doScope(
at org.eclipse.jetty.server.handler.ContextHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.HandlerList.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.Server.handle(
at org.eclipse.jetty.server.HttpChannel.handle(
at org.eclipse.jetty.server.HttpConnection.onFillable(
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
at org.eclipse.jetty.util.thread.QueuedThreadPool$
at Source)
Caused by: Network is unreachable: connect
at Method)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at com.sun.mail.util.SocketFetcher.createSocket(
at com.sun.mail.util.SocketFetcher.getSocket(
at com.sun.mail.smtp.SMTPTransport.openServer(
… 31 more

Where smtpAddress is the smtp address.

I am able to both ping the SMTP server and connect and send emails via telnet from the gateway machine.

From searching for the following Java error online I see others have had issues with Java using IPv6 over IPv4, so I’ve disabled the IPv6 under network adaptor properties but haven’t had any luck so far. Network is unreachable: connect

We are running an old rev of Ignition (soon to be upgraded) but I’ve briefly looked through the minor revision notes and can’t see any fixes specifically for this fault.

Does anyone have any clues as to why Java thinks it cannot connect to the SMTP server when the machine clearly can connect?

The machine is running Win 7 OS, Ignition 7.7.1.

Is there a firewall rule or some kind of windows policy preventing a process that is running as a service from making an outbound connection? :scratch:

I’ve done a few more tests which seem to indicate that it’s a machine based issue and not a firewall/policy issue. I’ve detailed my tests below:

  1. On a different gateway instance running on my laptop (same OS, Java version and Ignition version) I can successfully send an email through the same script.

  2. I’ve tried modifying the Java option parameters to prefer IPv4 by using the following command line command:


Then restarted the gateway with no success.

  1. I’ve tried wire-sharking the connection but not too sure what I’m looking for. I know that when I send the emails via Telnet I get some SMTP traffic, but it doesn’t get any when running the script on the gateway (there is no traffic going to the IPv4 IP address of the SMTP server at all). Unfortunately I can’t check the traffic on my laptop gateway instance to compare because it is going through a VPN.

So I haven’t been able to prove that the packets have even left the PC and the “try/except” clause on the “sendEmail” function fails with next to no delay. Does anyone have any other ideas I can try/diagnostics I can log to get a clearer picture of what is going on?

Just to update this post: after much head scratching and some help from the Inductive support guys the problem was narrowed down to an anti-virus setting. To quote Paul:

" the network unreachable error indicates that Ignition sent the connection request to Java, and then Java tried to send it to the OS - but the call was rejected at that point"

Now to go back and turn all the IPv6 settings back on…

1 Like