How to test SMTP Connection
Hello all and happy new year! Even if I should be on holiday I’m working from home, and while I’m waiting for me colleague to call me back from the office I’ve thought to post this sharing something I use often.
In my work I often deal with Mail servers, which were and still are my field of specialization, and one of the most basic tasks I deal with when installing new servers is checking SMTP daemon (or service) is working properly, as you know this is pretty easy to accomplish opening a telnet connection to the server we want to test and writing the verbs needed to the SMTP daemon. This is pretty easy and standard but I’m a lazy person and this morning while testing a new server I’ve written this little and dirty script to do the job for me
Here we go :
<pre lang="bash">#!/bin/sh ( echo HELO ccielogs.com sleep 2 echo MAIL FROM: sleep 2 echo RCPT TO: sleep 2 echo DATA sleep 2 echo Subject:Test-Mail! sleep 2 echo If you can read this, it Works!!! sleep 2 echo . sleep 2 echo QUIT ) | telnet XXX.XXX.XXX.XXX 25
To make this work all you have to do is to modify the Mail From and Rcpt to fields so that valid sender and recipients are listed (this is not strictly necessary but would help being able to read the test mail just to be extra sure), last modification needed is of course the IP address of the server to test.
Once copied all you have to do is to save the file as smtp.sh (or whatever name you like) and make it executable or launch it with sh smtp.sh.
If you you found this useful or informative please a moment to retweet it or leave a comment I would love to hear from you!