I am using java, and wilfly 17 running on ubuntu 18 and would like to send an e-mail via localhost / a remote host, i.e. gmail, using this server. I have implemented the solution described in
and then tried implementing the solution described in
But, unfortunately, in both cases I am getting one and the same exception
Couldn't connect to host, port: localhost, 25; timeout -1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;
nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209)
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
respectively:
Couldn't connect to host, port: mail.google.com, 25; timeout -1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: mail.google.com, 25; timeout -1;
nested exception is:
java.net.ConnectException: Connection timed out (Connection timed out)
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209)
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.api@1.6.2//javax.mail.Service.connect(Service.java:388)
Regarding allowing outbound connections on my Ubuntu system, I have allowed all outbound connections as described in
allow inbound/ outbound connections Ubuntu
I just have tried sending an email through WildFly 17 running on Windows 10, but I am getting the same exception as above:
(default task-6) Couldn't connect to host, port: mail.google.com, 25; timeout -1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: mail.google.com, 25; timeout -1;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209)
at javax.mail.api@1.6.2//com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.api@1.6.2//javax.mail.Service.connect(Service.java:388)