Cannot send mails via outlook through java application - java

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.

Related

Spring Boot - Java Mail - Couldn't connect to host

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.

Simple Java Mail SMTP host

I am using Simple Java Mail API in order to send emails from my Spring Boot application. The app's owner was my colleague who doesn't work with me now. In my application.properties file I have the following config
simplejavamail:
smtp:
host: 172.28.94.229
port: 25
javaxmail:
The question is that I can't understand what host is this? Which server my emails go to? Is this something provided by Simple Java Mail, but I couldn't find anything in their documentation.
This IP address is not publicly routable on the Internet but is reserved and used for private or local networks.
For you information the following IPv4 address spaces are not Internet routable:
10.0.0.0/8 IP addresses: 10.0.0.0 – 10.255.255.255
172.16.0.0/12 IP addresses: 172.16.0.0 – 172.31.255.255
192.168.0.0/16 IP addresses: 192.168.0.0 – 192.168.255.255
You can try the following command
telnet 172.28.94.229 25
and see if you get a timeout (meaning that no service is listening on that IP/Port) or you are connected to some service.
If this IP/Port exists and you get a connection opened, then you should ask your company's system admin for more information on that SMTP server.
If you cannot get connected, maybe this is just a mock / not real SMTP server.

Host Ip binding failed

I am trying to connect my genymotion emulator to my localhost. After reading an article I got to know that my emulator is running on virtual host so I need to run my application in the same network
So emulator is on ip 192.168.20.101 So I tried to keep my server on 192.168.20.5
I am using dropwizard server. I got an error java.net.BindException: Cannot assign requested address: bind
I used following code to change my yml file
server:
applicationConnectors:
- type: http
bindHost: 192.168.20.5
port: 8090
adminConnectors:
- type: http
bindHost: 192.168.20.5
port: 8091
I am not sure you can bind IP in inside VirtualBox network. What you can do is configure your device to run in bridge mode, like this:
This way the device runs in the same network as your host, so you can easily access localhost or other machines.

Mail sending -SMTP error with javaMailSender

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.

Could not connect to SMTP host error in my local only

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?

Categories

Resources