Docker Community Forums

Share and learn in the Docker community.

SMTP Service enablement inside Docker Container

docker

(Sivapalanisamy) #1

Hi Team,

I’m very new to Docker container concept. I have created docker containers for ELK and now am trying to achieve the SMTP mailing service inside my elastic container. But am unable to enable the SMTP service inside the container.:disappointed_relieved:

By the way, being able to send the mail from outside the container. SMTP service exposed port 25 in outside of the container.

lsof -i:25

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 2327 root 13u IPv4 33808 0t0 TCP localhost:smtp (LISTEN)
master 2327 root 14u IPv6 33809 0t0 TCP localhost:smtp (LISTEN)

Please find the config in below. Am trying to use the post 587 for SMTP in the container.
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
environment:
- cluster.name=fopr-cluster
- xpack.security.enabled=false
- “ES_JAVA_OPTS=-Xms10g -Xmx10g”
- xpack.watcher.enabled=true
- SMTP_TLS=true
- SMTP_HOST=smtp.gmail.com
volumes:
#- /data/elasticsearch/:/usr/share/elasticsearch/data
- /var/lib/docker/sms/elasticsearch:/usr/share/elasticsearch/data
ports:
- “9200:9200”
- “587:587”
networks:
- webnet
deploy:
restart_policy:
condition: on-failure
delay: 15s

"Caused by: com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: smtp.gmail.com, 587; timeout 120000
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2118) ~[?:?]
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712) ~[?:?]
at javax.mail.Service.connect(Service.java:366) ~[?:?]

Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:402) ~[?:?]
at java.net.Socket.connect(Socket.java:591) ~[?:?]
at com.sun.mail.util.WriteTimeoutSocket.connect(WriteTimeoutSocket.java:113) ~[?:?]
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:329) ~[?:?]
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238) ~[?:?]
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2084) ~[?:?]
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712) ~[?:?]
at javax.mail.Service.connect(Service.java:366) ~[?:?]
"
Could someone please help me to fix this issue. And please correct me if I missed out anything over here.

Many Thanks,
Siva.P


(Sivapalanisamy) #2

Team,

Could you please someone help me with the issue. Still am running behind the issue:disappointed_relieved:

Thanks in advance!

Siva.P


(Keithh) #3

Have you read up on how to expose the port you need? If you’re using docker-compose it’s just a one-liner in the config.