unable to send email on docker container from port 465 - java

I tried to send an email from port 465, it works well on IDEA. But when I deployed it on docker, the email send failed. The error message is:
javax.mail.MessagingException: Could not connect to SMTP host: smtpdm.aliyun.com, port: 465, response: -1
Then I tried to change the port to 25, the email sent success.
Change the smtp server seems nothing better.
How can I send mail from port 465 on docker container?

make sure that the port is available on the host machine and ports are mapped correctly when you start the docker image. also, make sure that postfix is installed in your docker image and is active (sudo postfix status or sudo systemctl status postfix).
if both of theses conditions are met but it still don't work please also Try to set these values to:
smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt
in /etc/postfix/main.cf in the docker container.

Related

GCP GKE SMTP port 465 connection reset

I've got a Spring Boot Java application that sends emails via SMTP port 465 (non-gmail email). My configuration:
spring:
mail:
host: ssl0.ovh.net
port: 465
username: mailer#external.pl
password: mailerPassword
Locally everything works fine. When I deploy it on GCP Kubernetes cluster I've got a connection reset exception. I've read that GCP recommends some external paid providers but for my solution it's too much of a complication. Additionally I know that port 25 is disabled on GCP -> I've got port 465.
I've tried to simply add a firewall egress rule to enable traffic on every port for my VPC but it also didn't help.
What am I missing? Can anybody help my solve this puzzle?
Additional info:
My Java application is served as a simple deployment in k8s. It is exposed through LoadBalancer service on port 80.
Making a curl from given managed pod works - I receive a correct 2xx responses from various sites.
It turned out that my config map port changed from 456 to 465 but I forgot to restart the app. It works like a charm without any NAT configuration or firewall rules. Thanks for your support.

Spring boot on docker container network unstable

I have a spring boot app that runs docker container on top of Linux.
The app is sending bulk email to internal employees.
We have around 10 thousand emails to be sent every night.
Each email took about 5ms to sent.
The mail server and docker spring is in same company network
The problem is, the mail application in docker sometimes cannot connect to mail server.
Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx, port: 25, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx, port: 25, response: -1
But if I run the spring boot application without docker, from same machine, everything works fine (all emails were sent and no error message logged)
The docker network seems unstable.
Is this needs tuning or something?
This is my dockerfile to create the container
FROM openjdk:11-jre-stretch
COPY cacerts /docker-java-home/lib/security
RUN mkdir conf
VOLUME /tmp
EXPOSE 8002
ARG JAR_FILE=build/libs/mailman-1.1.jar
ADD ${JAR_FILE} mailman.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/mailman.jar"]

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 open connection to the host, on port 23: Connect failed

I have extremely simple chat server (100 lines of code on Java) and it is working properly. When I'm testing it with Telnet on localhost everything is just fine. When I asked some of my friends to test it with telnet (telnet <myIP> <port>, the port I assigned is 5555, server is running on my PC with static IP) everything is just fine too, but one of my friends received the error
Could not open connection to the host, on port 23: Connect failed
when he was trying to connect. Every firewall, anti-virus and anti-spyware software is turned off from both sides. Why could some of my friends connect but not him? Where is the problem: is it on the server or his PC?
I had a similar issue before and what it turns out to be is the syntax. When I do:
telnet 192.168.10.10:3333
I will get the port 23 error but if I type in:
telnet 192.168.10.10 3333
I will get correct result.
Try to make the telnet connection as
telnet 192.168.10.10 3333
without using :
Your friend's Telnet client is obviously attempting to connect to port 23, not 5555 or 43839, since that's what it says in the error message he is getting.
Ask your friend to check the documentation for the Telnet client he's using, and make sure he's specifying the port the proper way.

Categories

Resources