1824983 Members
3663 Online
109678 Solutions
New Discussion юеВ

Re: mail check

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

mail check

I created a sendmail check script to see if the daemon is running or not. Plain and simple. I'm not the greatest scripter. I handle hardware and OS mainly.

Now that I can see that the sendmail service is active, Is there a true test I can issue and build it into my script? That is, does anyone out there truely check to see if it is functioning?
UNIX IS GOOD
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: mail check

Shalom,

I'm attaching some toys for this purpose that may be of help.

Inline is a script that actually sends a mail.

They were joint projects, I'm not a great scripter either.


#!/bin/sh
sub2(){
echo helo example.com
echo mail from:mailtester@example.com
echo rcpt to:${1}@${2}
echo data
echo subject:$USL end to end mail check
echo shmuel protter mail test
echo .
echo quit
}
WT=3
PRGN=$(basename $0)
case $1 in

1) USL="usbm.example.com ilbm.example.com ukbm.example.com"
DML="example.com"
USR=enterpris
;;
2) USL="usmail1.ndsamericas.com usmail2.example.com"
DML="example.com ndsexample.com"
USR=jfredmugs
;;
*) echo "Usage: $PRGN {1|2} ; 1 - test gates; 2 - test usmail"
exit
;;
esac
for D in $DML ; do
for S in $USL ; do
sub2 $USR $D |
while read A; do
echo $A
sleep $WT
done | telnet $S 25 2>&1 | grep -e $USR -e $S | grep -v ^22|grep -v Connect
done
done


SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Geoff Wild
Honored Contributor

Re: mail check

This will given you version info:

sendmail -bt -d0.1 < /dev/null

You could

telnet server 25

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Nobody's Hero
Valued Contributor

Re: mail check

Yes I left out 1 part.
Telnet closed. Gov't system.

Using a general user ID with minimal permissions to do the test. Possible?
UNIX IS GOOD
Geoff Wild
Honored Contributor

Re: mail check

If mail is running, you will be able to telnet to port 25...

echo quit | telnet svr001 25
Trying...
Connected to svr001.mydomain.net.
Escape character is '^]'.
220 svr001.mydomain.net ESMTP Sendmail @(#)Sendmail version 8.13.3 - Revision 1.000 - 1st August,2006/8.13.3; Thu, 17 May 2007 10:31:06 -0600 (MDT)
221 2.0.0 svr001.mydomain.net closing connection
Connection closed by foreign host.


Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: mail check

Generally just seeing if the sendmail daemon is running is sufficient. You can also examine /var/adm/syslog/mail.log periodically. If you really want to see if the sendmail daemon is responding then

telnet localhost 25
or
telnet remote_hostname 25
and then issue a "quit".

Probably the easiest way to do this is via Perl's Net::Telnet module.
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: mail check

Shalom,

telnet hostname 25

Does not use telnet server. It used the telnet client which is almost certainly available to test smtp which is open or we would not be having this discussion.

ssh can be manipulated with the -p command to do this test but is hardly worth it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Arturo Galbiati
Esteemed Contributor

Re: mail check

Hi,
%echo quit|telnet 0 25 2>&1|grep Sendmail
220 hpbbnn1.bbn.hp.com ESMTP Sendmail 8.9.3 (PHNE_31917)/8.9.3; Fri, 18 May 2007 09:40:38 +0200 (METDST)

This run fine on my HP-UX11i.
Rgds,
Art