how to save a copy to a directory

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to save a copy to a directory

d tbsky
hi:
    I want to save every email copy to a Maildir format directory.
just like "always_bcc", but put the mails in some directory outside
normal mail storage area.

   I wonder if this can be done with configuration, or I need to write
some transport script.

I tried to use "always_bcc=archive@localhost", but I don't know how to
let postfix save mails to "archive@localhost" to "/my_want_directory".

 I tried to use "mailbox_transport_maps =
hash:/etc/postfix/archive_local". and the file "archive_local" content
is "archive local:/my_want_directory/". but the logic seems wrong.

any hint for doing this job clean and easy?
thanks for help!!
Reply | Threaded
Open this post in threaded view
|

Re: how to save a copy to a directory

Wietse Venema
d tbsky:

> hi:
>     I want to save every email copy to a Maildir format directory.
> just like "always_bcc", but put the mails in some directory outside
> normal mail storage area.
>
>    I wonder if this can be done with configuration, or I need to write
> some transport script.
>
> I tried to use "always_bcc=archive@localhost", but I don't know how to
> let postfix save mails to "archive@localhost" to "/my_want_directory".
>
>  I tried to use "mailbox_transport_maps =
> hash:/etc/postfix/archive_local". and the file "archive_local" content
> is "archive local:/my_want_directory/". but the logic seems wrong.
>
> any hint for doing this job clean and easy?
> thanks for help!!

Use the local alias_maps feature.

ALIASES(5)                                                          ALIASES(5)

NAME
       aliases - Postfix local alias database format
        ...
       The format of the alias database input file is as follows:

       o      An alias definition has the form

                   name: value1, value2, ...
        ...
       /file/name
              Mail  is  appended  to  /file/name.  See local(8) for
              details of delivery to file.  Delivery is not  limited
              to  regular  files.  For  example,  to  dispose  of
              unwanted  mail,  deflect  it  to /dev/null.

If you deliver to file this way, the file needs to be writable by
the $mail_owner user (default: postfix).  The file will grow until
the mailbox_size_limit is reached, then further delivery will fail.

It may be possible to trigger one-file-per-message (maildir style)
deliveries with an alias destination of /directory/ ('/' at end is
required).  I don't remember it that would work. It still requires
directory write permission for user $mail_owner.

        Wietse

Reply | Threaded
Open this post in threaded view
|

Re: how to save a copy to a directory

d tbsky
Wietse Venema <[hidden email]>
> If you deliver to file this way, the file needs to be writable by
> the $mail_owner user (default: postfix).  The file will grow until
> the mailbox_size_limit is reached, then further delivery will fail.
> It may be possible to trigger one-file-per-message (maildir style)
> deliveries with an alias destination of /directory/ ('/' at end is
> required).  I don't remember it that would work. It still requires
> directory write permission for user $mail_owner.

thanks a lot for the hint!
it works fine. maildir style is working also.
on my system (rhel 7), the mail is written by user "nobody".

Regards,
tbskyd