Testing SMTP

A few days ago some folks requested me to test if SMTP was working. After doing some research and analyzing what I can with the limited set of permissions that I have, I thought in creating a script to do a few things.

The idea

Well the simple idea was to build a script to send me a few emails every a few minutes apart to test it out.


Well my simplest thought was not that the SMTP was broken but that the script that was being executed overlapped itself and provoked some sort of glitch catching the memory of the system and at the end having the emails not being sent.


So, to the simplest point what I did was crete a batch process that will send emails. You can accomodate this to your needs and use it at your own risk. The program can run in the background or from the cron, but if you run it from the CLI at the end, it will not quit until it finishes.

for i in {0..10}
    echo "time is: $DATE" > now.txt
    sendmail -v [email protected] < now.txt
    sleep 300

How to Execute it?

  1. Create the file using vi or uploading it:
    vi test.sh
  2. Provide the right permissions to the file:
    chmod 755 test.sh
  3. Execute it or run it from the cron (in this case from the CLI).


You will get some output like the following:

[email protected] Connecting to [] via relay...
    220 host ESMTP Sendmail 8.13.8/8.13.8; Fri, 21 Feb 2014 12:16:48 -0500
    >>> EHLO host
    250 host Hello localhost [], pleased to meet you
    250 HELP
    >>> MAIL From:[email protected] SIZE=38
    250 2.1.0 [email protected]... Sender ok
    >>> RCPT To:[email protected]
    >>> DATA
    250 2.1.5 [email protected]... Recipient ok
    354 Enter mail, end with "." on a line by itself
    >>> .
    250 2.0.0 s1LHGmir026050 Message accepted for delivery
    [email protected] Sent (s1LHGmir026050 Message accepted for delivery)
    Closing connection to []
    >>> QUIT
    221 2.0.0 host closing connection

For the obvious reasons it can be improved, but it was a simplest thing to catch my eye and run it faster. Hope it helps everybody if you are having some sort of this issue.

Written on February 24, 2014