Skip to content
Aug 14 / Greg

Linux Script To Test Secure POP3

I placed the script int he root folder as /root/poptest.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash
 
echo "x" | openssl s_client -connect 127.0.0.1:995 > /root/pop3test.txt
 
if grep -Fq "POP3 server ready" /root/pop3test.txt
then
    # code if found
    echo "found"
else
    # code if not found
    echo "not found"
    service zimbra restart
fi

I then created a cron job that runs every 15 minutes and calls the script.

It uses the openssl client to connect to the server. It then pipes this to a file named pop3test.txt. After this it checks the file for “POP3 server ready” which is the all clear message at the end of the file.

If it passes it does nothing. If it fails it restarts the zimbra service(this happens to be running on a zimbra server).

Good luck and happy popping.

Leave a Comment

 

*