Skip to content

Instantly share code, notes, and snippets.

@heartshare
Forked from stwalkerster/postmanage.sh
Created March 11, 2013 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heartshare/5136099 to your computer and use it in GitHub Desktop.
Save heartshare/5136099 to your computer and use it in GitHub Desktop.
#!/bin/bash
app="whiptail --backtitle 'Postfix Queue Manager - stwalkerster.net Cluster' --clear --nocancel"
while true; do
queue=`ls /var/spool/postfix/hold/`
menulist=""
for i in $queue; do
sender=`postcat -h /var/spool/postfix/hold/$i | grep "From: " | sed "s/From: //" | sed 's/"//g'`
menuitem=" "$i" \""$sender"\" "
menulist=$menulist$menuitem
done
command=$app' --menu "Postfix Queue Manager" 40 80 30 '$menulist' quit "Quit this application"'
choice=$( eval $command 3>&2 2>&1 1>&3 )
if [ "$choice" == "quit" ]
then
break
fi
while true; do
from=`postcat -h /var/spool/postfix/hold/$choice | grep "From: " | sed 's/"//g'`
subject=`postcat -h /var/spool/postfix/hold/$choice | grep "Subject: " | sed 's/"//g'`
command=$app' --menu "Postfix Queue Item '$choice'\n'$from'\n'$subject'" 20 80 10 ignore "Ignore this message" view "View this message content" headers "View this message headers" envelope "View the envelope" requeue "Requeue this message for delivery" delete "Delete this message"'
action=$( eval $command 3>&2 2>&1 1>&3 )
case "$action" in
ignore)
break
;;
view)
postcat -b /var/spool/postfix/hold/$choice | less
;;
headers)
postcat -h /var/spool/postfix/hold/$choice | less
;;
envelope)
postcat -e /var/spool/postfix/hold/$choice | less
;;
requeue)
postsuper -r $choice
break
;;
delete)
postsuper -d $choice
break
;;
*)
;;
esac
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment