#!/bin/bash # Check whether we're online: ping -c1 smtp.isomerica.net > /dev/null 2>&1 if [ $? != 0 ] ; then echo " Cannot connect to server; probably you're not online. Bye." ; exit 0 fi # check whether there's any queued mail at all if [ -z "$(/usr/bin/find /home/mpromber/.msmtp.queue/ -iname '*mail' -print0)" ] then echo "You have no queued mail. Bye." ; exit 0 # if there isn't, exit. fi # Else, display queued mail and offer options:" echo " *** Do you want to send the following messages? ***" msmtpq -d echo " (y)es, send all messages delete (i)ndividual messages from queue (d)elete all from queue (q)uit " read ANS # store user's answer in variable ANS case $ANS in # act accordingly: y) msmtpq -r # send all queued mail ;; i) msmtpq -p # delete individual messages ;; d) msmtpq -a # delete all ;; q) echo "Bye!"; exit # exit script ;; *) echo "Unknown option; can't do anything. Try again." # exit script esac