[Mimedefang] mimedefang send a copy of all mails to a directory

Bill Cole mdlist-20140424 at billmail.scconsult.com
Mon Jun 27 12:21:06 EDT 2016


On 27 Jun 2016, at 9:01, Shaun Megaw wrote:

> Hi
>
> I have the following entry
>
> sub filter_begin
> {
> system('cp', 'INPUTMSG', '/home/shaun');
> }
>
>
> This created a file called /home/shaun/INPUTMSG which is over written 
> by each new mail
>
> Is there a way to send a copy of all mails in individual files to a 
> directory?

Sure: it's called Maildir.

Postfix supports Maildir directly. With Sendmail you can use procmail or 
Dovecot's 'deliver' program to deliver to Maildir. Procmail also 
supports a less complex file-per-message directory structure that the 
'mh' mail reader uses which might suffice in you case but is less safe.

In mimedefang-filter, you can get every message dropped into a Maildir's 
'new' subdirectory by calling the add_recipient() subroutine in 
filter_end() with an address that you've configured for Maildir 
delivery. This does NOT add headers or any other data to the message(s) 
delivered to the the existing recipient(s).

The advantages of using a mature delivery agent into Maildir:

1. You get an established mechanism for naming and handling files, 
assuring that you cannot ever collide names and consumers can always be 
assured that they are looking at a completely-written file.

2. You get logging (if you want it) by your MTA and/or the delivery 
agent.

3. You can (if you want it) make a Maildir available via IMAP or (if 
you're nostalgic) POP.

> The reason I ask i we are using a archiving solution which imports 
> .eml files and I need to figure out a way to export all mails to .eml
>
> BCC filter will not work as the archiving server can only accept .eml 
> format

I don't know what exactly you are referring to as "BCC filter" but the 
file that Postfix or Courier or Procmail or Dovecot will deliver in 
~/Maildir/new/ is precisely identical to what a MUA will save as a .eml 
file after retrieving that message, with the possible exception of 
linebreak representations: on Windows a .eml has carriage returns, 
essentially every other modern system uses linefeeds. The MIMEDefang 
INPUTMSG file will also differ from the delivered message in that 
INPUTMSG lacks a local Received header. A delivered message (and hence a 
MUA-generated .eml) may also have headers which are added in the 
delivery process such as Return-Path, X-Original-To, and Delivered-To.



More information about the MIMEDefang mailing list