Gentoo Archives: gentoo-server

From: Paul Hartman <paul.hartman@×××××.com>
To: gentoo-server@l.g.o
Subject: Re: [gentoo-server] Postfix: Can I insert a custom header to incoming mail?
Date: Fri, 08 Jul 2011 03:06:42
Message-Id: CAEH5T2Nh-XSNNHTP2gmu-OwCk_teP4wUWFgnqk33n-NrfBhi7w@mail.gmail.com
In Reply to: Re: [gentoo-server] Postfix: Can I insert a custom header to incoming mail? by kashani
1 On Thu, Jul 7, 2011 at 7:41 PM, kashani <kashani-list@××××××××.net> wrote:
2 > On 7/7/2011 4:59 PM, Paul Hartman wrote:
3 >>
4 >> On Thu, Jul 7, 2011 at 5:25 PM, kashani<kashani-list@××××××××.net>  wrote:
5 >>>
6 >>> On 7/7/2011 2:50 PM, Paul Hartman wrote:
7 >>>>
8 >>>> The idea:
9 >>>>
10 >>>> Assuming I can't do anything about how Postfix handles the
11 >>>> Delivered-To header, I'd like to insert a new header entry
12 >>>> (X-Originally-To: or something like that) into incoming mail before it
13 >>>> hits the catchall forward, so I can know to whom the email was
14 >>>> originally addressed... but i don't really know where to begin.
15 >>>>
16 >>>> The question:
17 >>>>
18 >>>> Are there any postfix gurus out there who can point me in the right
19 >>>> direction? Thanks in advance for any tips or advice (or if you want to
20 >>>> tell me that I'm doing it all wrong).
21 >>>
22 >>> It should already be there at least in 2.7.4 which is stable unless
23 >>> you've
24 >>> really tweaked your main.cf. I'd run a postconf | grep enable_orig and
25 >>> see
26 >>> if it's not set to yes.
27 >>>
28 >>> kashani
29 >>>
30 >>> http://www.postfix.org/postconf.5.html
31 >>>
32 >>> enable_original_recipient (default: yes)
33 >>>
34 >>>    Enable support for the X-Original-To message header. This header is
35 >>> needed for multi-recipient mailboxes.
36 >>
37 >> Hi kashani,
38 >>
39 >> I actually read about that option when I was trying to make this
40 >> happen (forgot about it when composing my original message). Googling
41 >> that option I found that most people were interested in combining
42 >> multi-recipient messages to one on disk (to save space). Indeed the
43 >> option is already set to "yes" on my setup, but I still don't get that
44 >> header. I supposed that it has nothing to do with the address I'm
45 >> interested in (from the envelope) and instead is looking at the To:
46 >> name from headers (which is unchanged). Or because my message does not
47 >> have multiple recipients. But maybe I'm completely misunderstanding
48 >> what it's all about.
49 >
50 > I think I've got it figured out and this is your culprit.
51 >
52 > http://en.gentoo-wiki.com/wiki/Mail_server_using_Postfix_and_Dovecot#Dovecot_Integration_-_LDA
53 >
54 > This is because Postfix adds the x-original-to when it delivers, but not
55 > when it passes the mail via lmtp to Dovecot. See this Dovecot thread for
56 > some details.
57 >
58 > http://www.dovecot.org/list/dovecot/2011-January/056787.html
59 >
60 > The primary benefits of Dovecot LDA seem to be cache files and Sieve.
61 > http://wiki.dovecot.org/LDA/Indexing
62 > http://wiki.dovecot.org/LDA/Sieve
63 >
64 > If you aren't using Sieve, I would try is using virtual_transport = virtual
65 > instead of virtual_transport = dovecot
66 >
67 > You might need to change some settings in your Dovecot config to match where
68 > Postfix will deliver the emails, specifically mail_location =
69 > maildir:/var/mail/%d/%n/Maildir/:INDEX=/var/mail/%d/%n/indexes
70 >
71 > This are the settings I use for Postfix w/ Courier. Should work with
72 > Dovecot, but again you might need to change things a bit.
73 >
74 > # virtual stuff
75 > virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
76 > virtual_gid_maps = static:207
77 > virtual_mailbox_base = /var/mail/
78 > virtual_mailbox_domains =
79 > proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
80 > virtual_mailbox_limit = 512400000
81 > virtual_mailbox_maps =
82 > proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
83 > virtual_minimum_uid = 207
84 > virtual_transport = virtual
85 > virtual_uid_maps = static:207
86
87 Really great info, thanks a lot for taking your time to look into it.
88 I will experiment with it and see what I can do. Thankfully I'm just
89 using a new domain for testing for now, so I have the freedom to break
90 things as much as needed until I get it right. :)
91
92 Thanks again,
93 Paul