On 2011-08-10 09:20, Troy Piggins wrote:
Hi there, I have a few questions about sender_bcc_maps.
Until recently I have been using these to archive sent mail with a hash table
like this:
us...@mydomain.com user1_s...@mydomain.com
and some procmail rules took messages sent to user1_s...@mydomain.com and piped
it through gzip into a monthly archive file. That all works fine.
Recently my needs have become a little more complicated, and I think need
something more like a pcre table instead, just for these new rules.
I want to bcc arch...@mydomain.com all outgoing messages, as messages to this
address will be filing mails in specific project folders. But to prevent
loops, don't want to copy mails from arch...@mydomain.com, as well as some
other users I'd like to exclude from this. My attempt at handling this is this
pcre table:
if !/arch...@mydomain.com/
/.*@mydomain.com/ arch...@mydomain.com
endif
/us...@mydomain.com/ user1_s...@mydomain.com
/us...@mydomain.com/ user2_s...@mydomain.com
/us...@mydomain.com/ user3_s...@mydomain.com
and so on.
Some questions about the above.
1. Could you please confirm that the pattern between the slashes is just the
sender's address that we're trying to match?
sender_bcc_maps matches the envelope sender address.
At first I tried doing a full
header match like /^From:.*@mydomain.com/ but it didn't seem to be working
correctly. Not sure if that was my pattern or because it was looking for a
sender with From etc in the address.
The envelope sender is not a header.
2. Can you recommend a better or more elegant solution to the second part of
the table with the /us...@mydomain.com/ etc? I tried using something like
this:
/(user1)@mydomain.com/ \1_s...@mydomain.com
but it occurred to me that the variable \1 to the right is probably not
recognised outside the actual pattern within the //. Correct?
It is not a variable expansion. Use this instead:
/(user1)@mydomain.com/ $1_s...@mydomain.com
Read http://www.postfix.org/pcre_table.5.html, section Text Substitution for
details.
Note that this offers zero advantage over an exact match.
3. Do you think I'm on the right track? Mostly in terms of using pcre for the
table. Wasn't sure whether this or regex would be better?
I would probably use regexp tables; it's a matter of preference mostly,
although the documentation says PCRE is usually faster.
4. Any other suggestions/advice?
The easiest way to prevent matching the archive sender address on mail
you do not wish to archive is not to use that address as a sender, ever.
Use something like archive-from@; use your imagination.
--
J.