1823920 Members
3225 Online
109667 Solutions
New Discussion юеВ

sendmail check

 
Billa-User
Regular Advisor

sendmail check

hello,

i want to reorganize sendmail logfile "mail.log" in a script. so i stop sendmail, copy "mail.log" to a directory and start sendmail.

how can i check, if sendmail runs ?

i found some solutions, but in some cases, i have to install GNU products (which have a lot of Run-time dependencies) :

- lsof -i :25
- nmap -v -p 25 -sT localhost
- netstat -an |grep
- telnet localhost 25 <<
EO^]
close
EOF

what is the best way to check sendmail ?

regards
6 REPLIES 6
OldSchool
Honored Contributor

Re: sendmail check

I assume you are using:

/sbin/init.d/sendmail stop -and-
/sbin/init.d/sendmail start

to stop/start sendmail. If so, it shouldn't be an issue.

You might also simply examine the return code from the start command with *?. I believe it will return a non-zero if there are problems.

Two other alternatives:

UNIX95= ps -C sendmail -ocomm= | wc -l

should be 1 if sendmail is running,
or you might look at the section of code in the start-up script that is used to check the status:

pidfile="/etc/mail/sendmail.pid"
if [ -f $pidfile ]; then
test "$pidfile" && exec 0< $pidfile
read -r PID
sendserv=`ps -e | grep -E "^ [ ]*$PID .*sendmail" | wc -l`
if [ $sendserv -ne 0 ]; then
set_return
echo "sendmail has already been started"
exit $rval
fi
fi

Steven Schweda
Honored Contributor

Re: sendmail check

> [...] and start sendmail.

How?

> how can i check, if sendmail runs ?

Did anything go wrong when you started it?

Trying to send and receive e-mail is a pretty
good test.

You could look at that new log file, too.

"ps" could show you if there's a program
named "sendmail" running.

All those commands which mention "25" are
intended to tell you if anyone is listening
to the SMTP port (25). Sendmail should do
that.


> what is the best way to check sendmail ?

Best in what sense? Easiest? Most complete
and reliable? Checking actual e-mail
capability is probably the most realistic
test. Everything else is probably easier.
Steven Schweda
Honored Contributor

Re: sendmail check

Laying one more beating on a dead horse, ...

> UNIX95= ps -C sendmail -ocomm= | wc -l

> "ps" could show you if there's a program
> named "sendmail" running.

Note that this tells you if there's _a_
program named "sendmail" running. It does
not tell you if _the_ "sendmail" program is
running.


Why do you care if sendmail is running?

Why do you run sendmail?

If you run sendmail to handle e-mail, then
the real question is, "Does e-mail work?",
and the best test for that is a real e-mail
test. Anything else you test will give you
only an approximation of what you really wish
to know.

Now, if, for some reason, you can't run a
real e-mail test, then you may need to fall
back to some less informative test, but it's
good to know why you're testing what you're
testing, and what your test really tells you
(and what it doesn't).
Billa-User
Regular Advisor

Re: sendmail check

hello,

i know the problematic of "sendmail" and that it isn't possible to check whether a mail arrives the receiver (i can only search mail.log?) we had some cases that sendmail hung. this it what we want to check. and when a process runs, you can't say the process work's?
so we want to make a check :

- process exists
- process exists and works

but we don't want to send a email.

sendmail is our programm to send mail from unix to other destinations !

regards
Steven Schweda
Honored Contributor

Re: sendmail check

> sendmail is our programm to send mail from
> unix to other destinations !

You might try to arrange for a different
system to forward e-mail back to the system
being tested. For example:

On the test system, send an e-mail test
message to "mirror@reliable_system".

Arrange for e-mail to "mirror" arriving at
reliable_system to be forwarded (back) to,
say, "tester@test_system".

If the test message is not received by
"tester" on test_system, then there's a
problem somewhere. If it is received, then
you can be pretty sure that sendmail is
working properly on test_system.

It's been a long time since I've cared, but,
as I recall, you can rig an e-mail alias to
run a program when a message arrives for a
user (like "tester"), so you might not need
to log in manually as "tester" just to check
his e-mail.

In fact, you could rig things so that if the
test message didn't return, an e-mail
message would get sent to the system manager.
Of course, this might not work either, so
you might need to be a bit more clever than
that. ("Let me know if you don't receive
this message.") But many things are
possible.
Steven E. Protter
Exalted Contributor

Re: sendmail check

Shalom,

Most corporate mail systems is DSrelayserver configuration in sendmail.cf to relay mail via smtp relay hosts.

It is rare that a Unix system is permitted to simply resolve the domain name and deliver mail.

Note that you need not run the sendmail daemon to merely send outbound mail. You need the sendmail daemon to receive mail on a system.

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