I'm trying to copy weekly e-mails from one account to another. I don't want to simply give access to the mailbox to a certain user, because I want the e-mails to be persistent in case the user whose mailbox I copy the e-mails from chooses to delete them.
I came up with the following script:
Code: Select all
lweek=$(date -d "last week" +"%Y%m%d%H%M%S")
for mail in /opt/zimbra/store/0/2/msg/0/*
do
echo $mail
outp="$(awk '/^Date/ && $5 ~ /^[1-2][0-9]+$/ { print $3, $4, $5, $6; exit }' $mail)"
maildate=$(date -d "$outp" +"%Y%m%d%H%M%S")
if [ $maildate -gt $lweek ]; then
/opt/zimbra/bin/zmmailbox -z -m destination_account@domain.com addMessage /Inbox/tempo $mail
else echo "not applicable for mail"
fi
done
Thanks!