SMTP Test Script
Budget: $250 – $750 USD
This script will test the availability of a remote SMTP server (within our closed network) to potentially accept a message with a TLS based connection (STARTTLS). It will run on a Linux host with either Ubuntu 22 or with Oracle Linux 8. It should be able to support both TLS version 1.2 and 1.3. It should work on any port defined as defined in the remote host file.
The script, using a flat configuration file, will open a connection to a remote SMTP server and perform the initial handshake then release the connection. The script needs to update a flat file with the results of the test. The script will be called with a crontab entry on a periodic basis (~5 minutes).
If the remote SMTP server cannot be contacted in 4-6 seconds, it should be marked as failed and the script should move on to the next entry in the remote host list.
The host configuration file (/etc/sites.txt) may have up to 10 remote SMTP servers listed in it and these will be defined as fully qualified domain names and the port they accept mail on. The list will be a simple text formatted file with just the host names.
Example:
smtp.example.com:25
smtp.example.net:465
The output list (/tmp/results.txt) will be a very simple list of the remote SMTP servers and an indication of the results. This flat file will be used to help the routing on the new messages in the output queue. Often, one MTA may not have a working direct route to the final MTA but an alternate MTA may have a direct route (A to B via C). We do not want to send a message directly outward towards an MTA which is not directly (or indirectly) accessible to the originating MTA.
Basically we want to have real time routing of the message. If no route is available, the sender will know quickly as the originating MTA will advise the sender that no route is available within a few seconds. Thus, in the end, we are creating a small avoidance based routing configuration.
Example:
smtp.sample.com: 220 [time] (command accepted)
smtp.sample.net: 450 [time] (host not accepting mail)
There are a very wide variety of scripts (mostly created in Perl or Python) that available in the open source community. We think you can find one and then add the multiple host function and output file function to it. One module that is fairly complete and well respected would be to use this one (Nagios check_smtp Plugin found at GitHub [it is created in C]). You could even do this project just using bash commands.
Example: ./check_smtp xray.cellmail.com
SMTP OK - 0.127 sec. response time|time=0.126662s;;;0.000000
The problem in the results file is we are missing the host name.
Should be:
xray.cellmail.com SMTP OK - 0.127 sec.
To make this easy for you, we can install the “check_stmp” module in each host and you can just call it. The script would be at /usr/local/bin/check_smtp
We expect this is much less than an 8 hour job.
The script, using a flat configuration file, will open a connection to a remote SMTP server and perform the initial handshake then release the connection. The script needs to update a flat file with the results of the test. The script will be called with a crontab entry on a periodic basis (~5 minutes).
If the remote SMTP server cannot be contacted in 4-6 seconds, it should be marked as failed and the script should move on to the next entry in the remote host list.
The host configuration file (/etc/sites.txt) may have up to 10 remote SMTP servers listed in it and these will be defined as fully qualified domain names and the port they accept mail on. The list will be a simple text formatted file with just the host names.
Example:
smtp.example.com:25
smtp.example.net:465
The output list (/tmp/results.txt) will be a very simple list of the remote SMTP servers and an indication of the results. This flat file will be used to help the routing on the new messages in the output queue. Often, one MTA may not have a working direct route to the final MTA but an alternate MTA may have a direct route (A to B via C). We do not want to send a message directly outward towards an MTA which is not directly (or indirectly) accessible to the originating MTA.
Basically we want to have real time routing of the message. If no route is available, the sender will know quickly as the originating MTA will advise the sender that no route is available within a few seconds. Thus, in the end, we are creating a small avoidance based routing configuration.
Example:
smtp.sample.com: 220 [time] (command accepted)
smtp.sample.net: 450 [time] (host not accepting mail)
There are a very wide variety of scripts (mostly created in Perl or Python) that available in the open source community. We think you can find one and then add the multiple host function and output file function to it. One module that is fairly complete and well respected would be to use this one (Nagios check_smtp Plugin found at GitHub [it is created in C]). You could even do this project just using bash commands.
Example: ./check_smtp xray.cellmail.com
SMTP OK - 0.127 sec. response time|time=0.126662s;;;0.000000
The problem in the results file is we are missing the host name.
Should be:
xray.cellmail.com SMTP OK - 0.127 sec.
To make this easy for you, we can install the “check_stmp” module in each host and you can just call it. The script would be at /usr/local/bin/check_smtp
We expect this is much less than an 8 hour job.