akmadhwa.com

How to test mail server using telnet in docker container

Last month, I was given a task to set up a send-only mail server for docker and I found that telnet is quite handy to test your mail server is working or not. I just need to go to each container and telnet to my mail server container and send the email. If my mail server container is working, it will send to my inbox.

1. Installing telnet

If your Linux has not install telnet yet, run this command

1sudo apt udpate && sudo apt install telnet

If you are using alpine image

1apk update && apk add busybox-extras

2. Connecting to your mail server

After you successfully installed the telnet, you can start to connect to your server.

1telnet your-mail-server-name 25

Telnet will use port 23 by default if you do not specify the port number. Notice that SMTP uses 3 ports which are 25, 465, and 587 . Be careful when using port 25 because some cloud provider block this port by default to avoid spam. For example Digital Ocean and AWS are blocking port 25.

Once you are successfully connect to your server, backspace and delete key do not work. make sure you type correctly when you are inside telnet

3. Sending the email

1EHLO your-domain.com

If you success to say hello it will return like this

 1250-mail.port25.com says hello
 2250-STARTTLS
 3250-ENHANCEDSTATUSCODES
 4250-PIPELINING
 5250-CHUNKING
 6250-8BITMIME
 7250-XACK
 8250-XMRG
 9250-SIZE 54525952
10250-VERP
11250 DSN

4. Define the sender email

1MAIL FROM: <yourname@your-domain.com>

5. Define the recipient

If you have multiple recipient, execute this line with different recipient

1RCPT TO: <test@test.com>

6. Message

1DATA;

Put the email subject in the email

1subject: this is just a test

Insert the email body content

1Hello world

End the body with full stop

1.

Note: A full stop on a line by itself is the signal to the SNMP server that input has ended.

You will see the message OK followed by ID code which mean your email has been sent.

7. Quit from telnet terminal

just type quit and hit enter

1quit;

#telnet   #mail-server  

Reply to this post by email ↪