Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as Bash by Vladimir ( 1 year ago )
#!/bin/bash
# Postfix virtual transport -> Carbonio mailbox migration
# written by NERvOus (http://www.nervous.it) - 2009-12-25
# minor fixes by NERvOus (http://www.nervous.it) - 2013-07-23
# base folder where msgs will be imported
BFOLDER="old-mbox"
ZMMBOX="/opt/zextras/bin/zmmailbox"
BDIR=$(pwd)
echo You must run $0 from inside /var/mail/virtual directory
echo $0 expects to find the mailboxes in the current path!
echo The structure of maildirs must be as follows:
echo
echo "domain/username/{cur|new|tmp}"
echo "domain/username/subfolder1/{cur|new|tmp}"
echo "domain/username/subfolder2/{cur|new|tmp}"
echo ...
echo
echo All folders will be stored in a subfolder called $BFOLDER
echo The hierarchy of subfolders will be maintained under $BFOLDER.
echo
echo Press Enter to start, CTRL+C to abort.
read
# handle folders with a space inside, they are more common than you may
# think
IFS='
'
for p in $(find . -type d -name cur); do
DOMAIN=`echo $p | cut -d'/' -f2`
UNAME=`echo $p | cut -d'/' -f3`
DIRNAME=`echo $p | cut -d'/' -f4`
# this may fail, if folder already exists. Who cares. Ignore the
# error.
echo createFolder /$BFOLDER | $ZMMBOX -z -m $UNAME@$DOMAIN
if [ "$DIRNAME" == "cur" ]; then
echo Importing INBOX folder for $UNAME@$DOMAIN from $BDIR/$DOMAIN/$UNAME/ 1>&2
# we are importing the top level folder
echo addMessage --noValidation /$BFOLDER $BDIR/$DOMAIN/$UNAME/cur | $ZMMBOX -z -m $UNAME@$DOMAIN
echo addMessage --noValidation /$BFOLDER $BDIR/$DOMAIN/$UNAME/new | $ZMMBOX -z -m $UNAME@$DOMAIN
else
DIRNAME=$(echo $DIRNAME | sed -e 's/\/cur$//')
echo Importing folder $DIRNAME for $UNAME@$DOMAIN from $BDIR/$DOMAIN/$UNAME/$DIRNAME 1>&2
echo createFolder \'/$BFOLDER/$DIRNAME\' | $ZMMBOX -z -m $UNAME@$DOMAIN
echo addMessage --noValidation \'/$BFOLDER/$DIRNAME\' \'$BDIR/$DOMAIN/$UNAME/$DIRNAME/cur\' | $ZMMBOX -z -m $UNAME@$DOMAIN
echo addMessage --noValidation \'/$BFOLDER/$DIRNAME\' \'$BDIR/$DOMAIN/$UNAME/$DIRNAME/new\' | $ZMMBOX -z -m $UNAME@$DOMAIN
fi
done
Revise this Paste
Parent: 124826