On Thu, Apr 16, 2009 at 09:58:37AM +0530, Kurian Thayil 
([email protected]) wrote:

> I tried the script. Good work. But, one problem though. If the mail
> server is firewalled (Netfilter) and if its blocking the client (one
> where bash script is run - 192.168.0.10), then `telnet 192.168.0.20 25`
> will not give any reply but just tries to connect indefinitely. At that
> moment the script will not give the error message. Can we do anything
> about it?

You could abort the telnet using its escape sequence instead of
using smtp quit, i.e.,

#! /bin/bash
case "$( (sleep 5; echo -e '\033q') | telnet 192.168.0.20 25 2>&- )" in
  *'
220 '*) echo Success ;;
  *)    echo Failed ;;
esac

If you want to be friendly to the mail server you could do both:

case "$( (sleep 5; echo quit; sleep 5; echo -e '\033q') | telnet 192.168.0.20 
25 2>&- )" in

That will look a bit nicer in the mail server logs and may avoid
tripping some spam/attack detection tools.

Also, you may need to adjust the delays: the time a mail server
takes to respond to initial connection may vary a lot,
depending on things like its load and whatnot.
Quite a few even deliberately wait some 10 seconds just
to trip spamming software known to be too impatient.

-- 
Tapani Tarvainen


-- 
To UNSUBSCRIBE, email to [email protected] 
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to