Check pending mail in mail queue

I know the command mailq can check the pending mail in mqueue , and also have another command to check POSIX mail queue in server , now I will regularly check the mqueue manually , it is time consuming , would advise the script that could help to check the mail queue , and then send the details to me by sendmail ?

I am not want to handle this pending mail , I just would like to know how many pending mail in the mqueue , is there a script can do that ?
thanks in advance.

Hello ust3,

Whilst you have the commands to tell you interactively if the queue is blocked for some reason (e.g. the relay server that you pass mail to is not responding) then you will not receive the notification. That could be a flaw in your thinking.

Do you have other servers that could remote connect (rsh or ssh) and get them to report to you somehow? Of course, they may be unable to send mail if it is a wider problem.

Regards,
Robin

thanks reply,
yes , there are remote server , but I prefer use localhost to do the checking.

Thanks reply,

I am not want to know the reason of failure to send mail and how to fix the error , I just would like to know how many mail is in the mqueue in a time .

is there script could do that ? thanks