[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mail loss!



On Mon, 7 Feb 2000, Michael Meskes wrote:

> How about doing a lock on the mailbox prior to moving it? I do need it but
> then I use cat to copy my mail followed by a another cat to empty the box.
> So my operation certainly is not atomical. I switched over to cat after
> losing some mail due to a forced copy.

I use a nice BSMTP system with exim when I am on a modem. I have exim
deliver my domain to ~jgg/bsmtp/<domain> and use these two scripts.. You
could replace the scp with an rsync which would be able to resume
batches.. This routes the entire domain, *@foo.com into a bsmtp file..

white{jgg}~/bsmtp#cat rcvbatch 
#! /bin/sh

set -e

BATCH=$HOME/bsmtp/wakko

lockfile $BATCH.transit.lock
trap "rm -f $BATCH.transit.lock > /dev/null 2>&1" exit

ssh white bsmtp/getbatch | gzip -d > $BATCH
ssh white rm bsmtp/wakko.transit
exim -bS < $BATCH
rm $BATCH

white{jgg}~/bsmtp#cat getbatch 
#!/bin/sh
set -e

BATCH=$HOME/bsmtp/wakko

lockfile $BATCH.transit.lock
trap "rm -f $BATCH.transit.lock > /dev/null 2>&1" exit

# Send an old batch
if [ -e $BATCH.transit ]; then
   gzip -9f < $BATCH.transit
   exit 0
fi

# Create a new batch
lockfile $BATCH.lock
if [ ! -e $BATCH ]; then
  rm -f $BATCH.lock > /dev/null 2>&1
  echo "No Mail" 1>&2
  exit 1  
fi

mv $BATCH $BATCH.transit
rm -f $BATCH.lock > /dev/null 2>&1

# Transmit
gzip -9f < $BATCH.transit
exit 0

Jason


Reply to: