procmail
[Top] [All Lists]

Re: archiving sent mail

2009-10-14 03:13:30
* Troy Piggins wrote :
I've been doing a little reading on this, and am aware that procmail
filters incoming, not outgoing, mail.  There are suggestions that
somehow use postfix's sender_bcc_maps to send a bcc of all outgoing
mail to an address that can be used to archive.  I have successfully
made the postfix adjustments to do this, I think, but having
trouble getting procmail to handle the bcc mails.

At present I'm archiving incoming emails by month:

DATE=`date '+%y%m'`
:0c:
| gzip -fc9 >> $HOME/mbox_$DATE.gz

I'd like to do similar with the sent mail.  I have set up postfix to
create a bcc mail of all mail originating from our domain name to
archiver(_at_)our(_dot_)domain(_dot_)name

I've changed this now so that postfix bcc's mail sent from
user(_at_)our(_dot_)domain(_dot_)com to 
user_sent(_at_)our(_dot_)domain(_dot_)com to make simpler
procmail rules below.

I was going to use something like this to archive them similar to
the incoming one above:

DATE=`date '+%y%m'`
:0
* ^TO_(_dot_)*archiver(_at_)our\(_dot_)domain\(_dot_)name
{
  FROM_USERNAME=`formail -rt -xTo: \
       | sed -e 's/[;\`\\]/ /g' \
       | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g' \
       | cut -f 1 -d @`

  :0c
  | gzip -fc9 >> /home/${FROM_USERNAME}/Sent_${DATE}.gz
}

I've simplified this now to:

:0
* ^X-Original-To:(_dot_)*_sent(_at_)lowstump\(_dot_)com\(_dot_)au
| gzip -fc9 >> ${HOME}/Sent_${DATE}.gz

and initial testing shows it working.

<snip />
Any ideas?  Initially I thought it might be the TO_ macro doesn't
handle BCC, but reading man procmailrc I think it does.

Still having trouble with this a little.  The ^TO_ didn't pick up
the BCC headers, so had to use the ^X-Original-To: one above.

-- 
Troy Piggins
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>