Postfix, maildir's, and writing filters

George Fazio gfazio at n3gqf.us
Tue Sep 23 12:21:39 UTC 2008


Da Rock wrote:
> On Mon, 2008-09-22 at 20:53 -0400, George Fazio wrote:
>   
>> Da Rock wrote:
>>     
>>> Howdy. This may seem simple, but I'm completely green on this: I have a
>>> postfix server with a courier-imap client frontend using maildir's. I'm
>>> using imap for an internal mta, but I need to setup a system which
>>> retains copies of sent emails on the network and not on individual
>>> workstations (which is what happens currently).
>>>   
>>>       
>> When you say courier-imap client, do you mean you're using maildrop to 
>> deliver the message to the user's maildir or that there is an end-user 
>> courier-imap client?  I am only familiar with the maildrop piece of courier.
>>     
>>> I've looked at some of the solutions (bcc and send to a psuedo account
>>> for each user, bcc to the user and filter the incoming mail on this) but
>>> it seems like a very roundabout way of doing things. I've read up on
>>> Postfix, and there is support for custom filters, so:
>>> 1. what does it take to write one?
>>> 2. how does one copy email from one folder to another in maildirs? Is it
>>> possible?
>>>
>>>   
>>>       
>> This is a classic case of over engineering.  You do not want to bcc back 
>> to the user, or filter the mta, just move the outgoing messages to the 
>> sent folder.  You might need bcc for the purposes of journaling all 
>> email, if you have any legal requirement (sox, hippa, etc.) that require 
>> it.  But, that it another ball of wax entirely.
>>     
>>> This idea I have should filter the outgoing mail and copy the messages
>>> to the sent folder as well as retaining its place in the queue.
>>>
>>>   
>>>       
>> If the end-user's client is using imap and configured properly, it 
>> should do this for you.  Thurderbird, the full version of Outlook (and 
>> probably Express), and many other clients support this natively - you 
>> just have to make sure the client is configured to do that.  Typically, 
>> in the configuration of the client, there is something that says 
>> something like "save a copy of sent messages to <folder of choice>".  I 
>> don't know what client you're using.  I use Pine/Alpine, Thunderbird, 
>> and Outlook (when I have no other choice).
>>
>> If the end-user's client is using pop, then you have a problem that may 
>> require a custom solution like you speak of above.
>>     
>>> Any ideas? Maybe a link to some good info? I would like to know how to
>>> do this myself so I can do more in the future so info and pointers would
>>> be great (if you have a script you'd like to share then please show me
>>> how it works :) ).
>>>
>>> Cheers
>>>
>>>   
>>>       
>> My mail system is running postfix (mta) w/ dovecot (for imap or pop 
>> access from the clients), maildrop (for delivering to a maildir), and 
>> amavis-new (for spam filtering and virus scanning w/ clamav).  My mail 
>> clients are configured for imap, and they save copies of sent mail to 
>> the sent folder as expected.  While I am using dovecot, and not courier, 
>> for my imap server - I cannot imagine that any other imap server would 
>> handle things any differently ... it's core functionality that ever imap 
>> server should have imho.
>>
>> -George
>>
>>     
>
> Me too. It may be possible to save a copy in evolution, but I haven't
> found it in all clients. Plus my system needs to be suitable for a
> webmail system, and yes some pop clients.
>
> You sound like you know maildrop very well, I was considering using it
> as a part of the solution. If I wrote a milter script for postfix, is it
> possible to pass the message to maildrop so that it can take care of the
> formalities such as filenames and formats and tell it to put it in a
> sent folder? Something like a shell or perl script that uses this line
> to run maildrop:
>
> maildrop -d $user Maildir/.Sent
>
> Obviously the message itself will be piped, and the $user will be
> obtained by copying the from field in the message.
>
> Would something like this work? I've been searching on google but
> haven't found a clear answer, they only mention using maildrop filters
> and commands there- not actual usage of the maildrop cli.
>
> Cheers
>
>   
If you wrote a filter for postfix, which I have no idea how to do, the 
maildrop command you sight looks good.

A friend of mine is using round cube for web mail (I don't have webmail 
setup on my server), and it will also save a copy to the sent folder.  
Most of the web clients should provide this functionality.  The pop 
clients are the ones that are going to be an issue.

I'm not sure what Google is using for gmail.  But, when I send a message 
using their smtp service, a copy goes into my account.  So, what you're 
looking to do is obviously possible, but I do not have an experience 
with it as I have not had need for a solution yet.  I would certainly be 
interested in what you come up with though.

Another possible option is to configure the clients to always bcc the 
sender, and then write a maildrop rule.  Something like "if 
(/^From:.*user\@domain\.com/) to Maildir/.Sent" might work (I have not 
tested this rule, it may not function as desired).  That would have to 
go in the .mailfilter file in each user's home dir.  I think you can 
have global maildrop rules if I remember correctly.  You might be able 
to sub user for a variable that contains the user name or the message 
sender, or something like that, so that you do not have to modify the 
.mailfilter file for every user.

Good luck...

-George



More information about the freebsd-questions mailing list