Usage: smtry [ -a | -q queueid | -s sender | -r recipient ]
-a Try ALL queued Sendmail jobs
-q queueid Try job queued for specified queueid
-s sender Try jobs queued for specified sender
-r recipient Try jobs queued for specified recipient
Note: A partial specification of queueid, recipient, or sender is effective
as a substring and the specification is not case-sensitive. Wildcards and
regular expressions are not allowed.
So for example, to process all those messages backed up to someone@odds.com,you could just type: smtry -r odd
I hope you find it helpful.
Code: Select all
#!/bin/sh
# @(#) smtry - Try Sendmail jobs by queueid, recipient, sender, or all
# Requires Sendmail
$DBG_SH # Debugging directive
Flag="" # Initially, no user-specified flag
# Function to handle usage errors:
usage_exit() {
echo "$*" >&2
cat << !EOF! >&2
Usage: `basename $0` [ -a | -q queueid | -s sender | -r recipient ]
-a Try ALL queued Sendmail jobs
-q queueid Try job queued for specified queueid
-s sender Try jobs queued for specified sender
-r recipient Try jobs queued for specified recipient
Note: A partial specification of queueid, recipient, or sender is effective
as a substring and the specification is not case-sensitive. Wildcards and
regular expressions are not allowed.
!EOF!
exit 1
}
# Check initial command-line argument count:
case $# in
1|2) ;; # okay, if one or two
*) usage_exit "Invalid invocation argument count" ;;
esac
# Process command-line options:
while [ $# -gt 0 ]; do
case $1 in
-a) [ "$Flag" ] && usage_exit "Only one option allowed"
Flag=X ; /usr/sbin/sendmail -v -q ; shift ;;
-q) [ "$Flag" ] && usage_exit "Only one option allowed"
[ "$2" ] || usage_exit "-q option requires an argument"
Flag=X ; /usr/sbin/sendmail -v -qI${2} ; shift ; shift ;;
-r) [ "$Flag" ] && usage_exit "Only one option allowed"
[ "$2" ] || usage_exit "-r option requires an argument"
Flag=X ; /usr/sbin/sendmail -v -qR${2} ; shift ; shift ;;
-s) [ "$Flag" ] && usage_exit "Only one option allowed"
[ "$2" ] || usage_exit "-s option requires an argument"
Flag=X ; /usr/sbin/sendmail -v -qS${2} ; shift ; shift ;;
--) shift ; break ;; # end of option list
-*) usage_exit "Unrecognized option \"$1\"" ;;
*) break ;;
esac
done