I am getting this error while trying to send mail through java mail. It used to work for me, but recently I switched to jdk7 and glassfish 3.1.2. I tried to switch it back to jdk6 also but it's not working anymore, here is the error I'm getting:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.illumina.com, port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect
Telnet and ping to this server is fine. Its working from other systems. Only my local setup is throwing this error.
Any ideas?
Related
I've implemented the email manager using JavaMailSender into my Java application, configured with Gmail email, and locally tested.
I'm using a free domain by freenom.
in localhost on my pc everything working perfectly. But deploying on the server the application obtains this error:
c.m.a.m.components.EmailManager : sendRegisterEmail Exception: Mail server connection failed;
nested exception is com.sun.mail.util.MailConnectException:
Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com. Failed messages:
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com
test done
Generating an application password
Using directly the host IP
Using port 465 and 25
Disabling VPS firewall
Used another mail provider
application.properties
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=***********#gmail.com
spring.mail.password=***********
spring.mail.properties.mail.debug=false
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.mime.charset=UTF-8
spring.mail.transport.protocol=smtp
Try to change spring.mail.port to 465. This might help.
Port 587 is technically correct. However, many ESPs have adopted implicit TLS on port 465.
Also, there's probably a firewall preventing you from connecting directly, you may need to connect through a proxy.
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
send mail via localhost
and then tried implementing the solution described in
send mail via remote host
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)
Thank you guys for your comments!
Ultimately I solved the problem by following exactly the steps listed here:
Configure WildFly to send eMails
then, after having recieved the exception
javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8
I logged on into my gmail account, on behalf of which I wanted to send e-mails, and enabled the option in this link:
Enable less secure apps gmail
Then I tested my solution on both Ubuntu 18.04 and Windows 10 and it worked in both cases!
I am running a program to send email using spring boot with gmail smtp.
The same code works fine in my personal laptop.
But when I try to run it in office laptop it doesn't work and says
SMTP timeout:
Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
I feel it is because of firewall or proxy.
I tried to check from Outlook but could not get smtp name , i tried some hit and trial also.
Any possible solution.
I have an RMI server and RMI client programs, when I execute RMI server on unix machine, and RMI client on Windows machine, I am getting
java.rmi.ConnectException: Connection
refused to host: ; nested exception is: java.net.ConnectException:
Connection refused: connect at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at the client side. I am able to execute on server and client on windows system but the server on linux is not working.
I searched using google, but I am unable to find the reason and fix.
I would appreciate your help.
Thank you in advance!
Referring the url
java.rmi.ConnectException: Connection refused to host: 127.0.1.1;
I added a line to /etc/hosts file and it works, but I am accessing the host using the IP address in my client program.
I did not understand why do we need to add a line to the /etc/hosts file.
Any comments. Thank You!.
Have the following mail configuration settings :
mail.smtp.host=smtp.us.deloitte.com
mail.smtp.socketFactory.port=25
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.auth=true
mail.smtp.port=25
and the following properties :
mail.password=password
mail.from=sam#xyz.com
mail.to=sam#xyz.com
mail.subject=Status of Data pushed
I get the following error :
java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.us.deloitte.com, port: 25;
nested exception is:
java.net.SocketException: Permission denied:
The same code when I use gmail as the 'from' account and the Outlook account in 'to', it works.
I tried setting setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true, also disabled iPv6 on Windows 7 box, but nothing seems to work
Just an observation: You are using STMPS protocol, and most SMTPS servers still communicates on the deprecated port 465 or the standardized port 587 and not 25.