Operating System - HP-UX
1830888 Members
1494 Online
110017 Solutions
New Discussion

Re: Internet mail - status confirmation

 
Bruce Pullen
Occasional Contributor

Internet mail - status confirmation

Is there a unix command to confirm that internet mail is running and reaching recipients.
6 REPLIES 6
David Rodman
Frequent Advisor

Re: Internet mail - status confirmation

A single command - no.
You can verify the mail progam is running by
ps -ef | grep sendmail

You can see the pending mail queue by
mailq

Assuming a default install, you can see logged messages
leaving your system by
more /var/adm/syslog/mail.log

Charles McCary
Valued Contributor

Re: Internet mail - status confirmation

Bruce,

I'm assuming from your question that you're going to try and implement some sort of script to check and make sure that sendmail is working correctly, if that is the case:

# example script
IS_IT_EMPTY=`mailq`
IS_IT_RUNNING=`ps -eaf | grep sendmail | grep -v grep`

if [ "${IS_IT_EMPTY}" = "Mail queue is empty" ]
then
if [ "${IS_IT_RUNNING}" != '' ]
then
echo "its running"
else
echo "there's a problem w/ sendmail"
else
echo "mailq not empty"
fi

someone_4
Honored Contributor

Re: Internet mail - status confirmation

Here is a menu script that have that does everything. The good part is that this makes it easy for anyone to check things.


# by Richard Leon
export TERM=vt100
clear
trap "echo User Aborted Command" 2
while [ "${X}" != "Q" ]
do
clear
echo ""
echo ""
echo " Welcome to Mail Surveillance & Troubleshooting Main Menu"
echo ""
echo " ********************************************************************"
echo "The rules of engagement are as follow:"
echo "PRESS 'Q' to quit this program and then type 'exit' to logout"
echo "PRESS 'Ctrl-C' to break out of a runnnig option "
echo ""
echo " ***Please look closely - These options have changed***"
echo "-------------------------------------------------------------------------"
echo ""
echo "PRESS '1': To check the mail queue"
echo ""
echo "PRESS '2': To view mail logs"
echo ""
echo "PRESS '3': To clear mail logs"
echo ""
echo "PRESS '4': To stop sendmail"
echo ""
echo "PRESS '5': To start sendmail"
echo ""
echo "PRESS '6': To grep for sendmail"
echo ""
echo "-------------------------------------------------------------------------"
echo ""
echo " make you choice: \c";read X
echo ""
##########################################
# MAIL QUEUE
if [ "${X}" -eq "1" ]; then
clear
echo "PRESS 'Ctrl-C' to break out of a runnnig option "
echo ""
mailq
echo ""
echo " Press Enter to Continue... \c"; read C
fi
#############################################
# VIew Logs
if [ "${X}" -eq "2" ]; then
cd /var/adm/syslog
clear
echo "PRESS 'Ctrl-C' to break out of a runnnig option "
echo ""
more mail.log
echo ""
echo " Press Enter to Continue... \c"; read C
fi
#############################################
# clear Logs
if [ "${X}" -eq "3" ]; then
cd /var/adm/syslog
clear
echo "PRESS 'Ctrl-C' to break out of a runnnig option "
echo ""
> mail.log
echo " Mail.log is cleared "
echo ""
echo " Press Enter to Continue... \c"; read C
fi
#############################################
# Stop Sendmail
if [ "${X}" -eq "4" ]; then
clear
echo ""
echo " Are you sure you want to stop sendmail?"
echo " Press 1 for YES or 2 for NO: \c";read Y
if [ "${Y}" -eq "1" ]; then
clear
/sbin/init.d/sendmail stop
echo ""
echo "Sendmail Has Stopped"
echo ""
fi
if [ "${Y}" -eq "2" ]; then
clear
echo ""
echo "You Decided not to Stop Sendmail"
echo ""
fi
echo " Press Enter to Continue... \c"; read C
fi
#############################################
# Start Sendmail
if [ "${X}" -eq "5" ]; then
clear
echo ""
echo " Are you sure you want to start sendmail?"
echo " Press 1 for YES or 2 for NO: \c";read Y
if [ "${Y}" -eq "1" ]; then
clear
/sbin/init.d/sendmail start
echo ""
echo "Sendmail Has Stopped"
echo ""
fi
if [ "${Y}" -eq "2" ]; then
clear
echo ""
echo "You Decided not to Start Sendmail"
echo ""
fi
echo " Press Enter to Continue... \c"; read C
fi
##############################################
# Grep Sendmail
if [ "${X}" -eq "6" ]; then
clear
echo "PRESS 'Ctrl-C' to break out of a runnnig option "
echo ""
ps -ef | grep sendmail | grep -v grep
echo ""
echo " Press Enter to Continue... \c"; read C
fi
#############################################



done
clear
someone_4
Honored Contributor

Re: Internet mail - status confirmation

Also on sendmail you can do
______________________________
sendmail -v user@domain.com
Text you want to send
.
____________________________
The . at the end sends the email.
This will show you allot of info that is helpfull in trouble shooting where the mail is going and where it is dying.

Richard
Bruce Pullen
Occasional Contributor

Re: Internet mail - status confirmation

Thanks to everyone for your assistance. We'll be using this info forthwith!
Robin Wakefield
Honored Contributor

Re: Internet mail - status confirmation

Another quick tip - if your queue is v. large, mailq can take a while, especially if all you want is the total number of messages currently in the queue.

Use:

mailq -Omaxqueuerunsize=1

to speed things up.

Robin.