RE: [Exim] Resending mail - my solution

Góra strony
Delete this message
Reply to this message
Autor: Michael Griffin
Data:  
Dla: exim-users
Temat: RE: [Exim] Resending mail - my solution
Greetings

After much digging, this is what I came up with. It may or may not
help some people :

#!/bin/bash
# Version 0.01
# 6 May 2003 Michael Griffin
#
# Re-sending mail in MailDir directories
# Basically taking the contents of a business mail email store and
# re-spooling it for delivery. Possible reasons are for when clients
# have moved away, changed to mail spooling or cancelled a user /
domain.
#
# USAGE : redeliver <recipient address>
#
# This script MUST be used from within the
<path_to_spool>/<domain>/<localpart>/Maildir/new
# or /cur directories. Using the command anywhere else will result is
junk and I mean serious
# junk being sent to the specified receint which is a really bad idea!!!
#

# Create a backup directory this specific time run
BACKUP=.backup.`/bin/date +%y%m%d%H%M%S`
mkdir $BACKUP

# Set a few constants
DATE=`/bin/date +%d" "%b" "%y" "%T`
NUMBER=0

# Pull in the command line address
RECIPIENT=$1

# Start the script
/bin/echo $DATE Redeliver process started >> .redeliver.log

for BLAH in `ls | grep mweb`; do \
SENDER=`/usr/bin/head $BLAH | /bin/grep Return-path | /bin/awk {'print
$2'} | /bin/sed -e "s/<//" -e "s/>//"`; \
`/usr/sbin/exim -f $SENDER -oi -oem -bm $RECIPIENT < $BLAH`; \
`/bin/mv $BLAH $BACKUP`; \
DATE=`/bin/date +%d" "%b" "%y" "%T`; \
let NUMBER=$NUMBER+1;\
`/bin/echo $DATE FILE : $BLAH SENDER : $SENDER RECIPIENT :
$RECIPIENT - $NUMBER >> .redeliver.log`; \
sleep 1;\
done
.redeliver.log
/bin/echo $DATE Redeliver process completed after $NUMBER files parsed
>> .redeliver.log





R e g a r d s

M i c h a e l L G r i f f i n

> -----Original Message-----
> From: William Thompson [mailto:wt@electro-mechanical.com]
> Sent: 06 May 2003 13:55
> To: Michael Griffin
> Cc: exim-users@???
> Subject: Re: [Exim] Resending mail
>
>
> > From time to time I need to convert a email address (with MailDir
> > delivery) to an Alias. This in itself is easily done
> however there is
> > still mail in the MailDir directory for this address that I need to
> > put back into Exim's MailQ for delivery using the new alias
> / setting.
> >
> > A brief example may be of assistance : (info supplied is
> fictitious
> > for security reasons)
> >
> > I have an address EG : snowball@???
> > The mail is received by exim and stored in :
> >
> >     /var/spool/exim/n/northpole.com/snowball/MailDir/new
> (then 'cur' once
> > read)
> >     Each e-mail is contained in individual files eg :
> > 1052142445.2126.<hostname>

>
> exim -f <senderaddress> -oi -oem -bm <newaddress> <

/var/spool/exim/n/northpole.com/snowball/MailDir>
/new/1052142445.2126.<hostname>
>
> ?
>