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 00:06:43
Message-Id: CAEH5T2PorCJk9ibTxm5f5LQ--3+cEx+6psiVFYhN6U9URheEUQ@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 5:25 PM, kashani <kashani-list@××××××××.net> wrote:
2 > On 7/7/2011 2:50 PM, Paul Hartman wrote:
3 >>
4 >> The idea:
5 >>
6 >> Assuming I can't do anything about how Postfix handles the
7 >> Delivered-To header, I'd like to insert a new header entry
8 >> (X-Originally-To: or something like that) into incoming mail before it
9 >> hits the catchall forward, so I can know to whom the email was
10 >> originally addressed... but i don't really know where to begin.
11 >>
12 >> The question:
13 >>
14 >> Are there any postfix gurus out there who can point me in the right
15 >> direction? Thanks in advance for any tips or advice (or if you want to
16 >> tell me that I'm doing it all wrong).
17 >
18 > It should already be there at least in 2.7.4 which is stable unless you've
19 > really tweaked your main.cf. I'd run a postconf | grep enable_orig and see
20 > if it's not set to yes.
21 >
22 > kashani
23 >
24 > http://www.postfix.org/postconf.5.html
25 >
26 > enable_original_recipient (default: yes)
27 >
28 >    Enable support for the X-Original-To message header. This header is
29 > needed for multi-recipient mailboxes.
30
31 Hi kashani,
32
33 I actually read about that option when I was trying to make this
34 happen (forgot about it when composing my original message). Googling
35 that option I found that most people were interested in combining
36 multi-recipient messages to one on disk (to save space). Indeed the
37 option is already set to "yes" on my setup, but I still don't get that
38 header. I supposed that it has nothing to do with the address I'm
39 interested in (from the envelope) and instead is looking at the To:
40 name from headers (which is unchanged). Or because my message does not
41 have multiple recipients. But maybe I'm completely misunderstanding
42 what it's all about.
43
44 Here's what an incoming mail to catchall looks like in my syslog:
45
46 Jul 4 22:11:10 virtual postfix/smtpd[3032]: connect from
47 mail-iw0-f174.google.com[209.85.214.174]
48 Jul 4 22:11:10 virtual sqlgrey: grey: domain awl match: updating
49 209.85.214(209.85.214.174), gmail.com
50 Jul 4 22:11:10 virtual postfix/smtpd[3032]: E66CA19F0D:
51 client=mail-iw0-f174.google.com[209.85.214.174]
52 Jul 4 22:11:10 virtual postfix/cleanup[3043]: E66CA19F0D:
53 message-id=<4E127EDC.6050308@×××××.com>
54 Jul 4 22:11:11 virtual postfix/qmgr[2633]: E66CA19F0D:
55 from=<paul.hartman@×××××.com>, size=1689, nrcpt=1 (queue active)
56 Jul 4 22:11:11 virtual dovecot: auth:
57 mysql(/var/run/mysqld/mysqld.sock): Connected to database postfixadmin
58 Jul 4 22:11:11 virtual dovecot: lda(catchall@×××××××.com):
59 msgid=<4E127EDC.6050308@×××××.com>: saved mail to INBOX
60 Jul 4 22:11:11 virtual postfix/qmgr[2633]: E66CA19F0D: removed
61 Jul 4 22:11:11 virtual postfix/pipe[3045]: E66CA19F0D:
62 to=<catchall@×××××××.com>, orig_to=<xyz@×××××××.com>, relay=dovecot,
63 delay=0.22, delays=0.18
64 /0.01/0/0.03, dsn=2.0.0, status=sent (delivered via dovecot service)
65 Jul 4 22:11:41 virtual postfix/smtpd[3032]: disconnect from
66 mail-iw0-f174.google.com[209.85.214.174]
67
68 So it does run cleanup (and before passing the msg to dovecot) and
69 there is reference to orig_to so at least I know postfix realizes
70 there's a difference. Maybe this should be done by dovecot instead?
71
72 Here is my main.cf (comment blocks removed):
73
74 [cut]
75 queue_directory = /var/spool/postfix
76 command_directory = /usr/sbin
77 daemon_directory = /usr/lib64/postfix
78 data_directory = /var/lib/postfix
79 mail_owner = postfix
80 myhostname = virtual.example.com
81 unknown_local_recipient_reject_code = 550
82 debugger_command =
83 PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
84 ddd $daemon_directory/$process_name $process_id & sleep 5
85 sendmail_path = /usr/sbin/sendmail
86 newaliases_path = /usr/bin/newaliases
87 mailq_path = /usr/bin/mailq
88 setgid_group = postdrop
89 html_directory = /usr/share/doc/postfix-2.8.3-r2/html
90 manpage_directory = /usr/share/man
91 sample_directory = /etc/postfix
92 readme_directory = /usr/share/doc/postfix-2.8.3-r2/readme
93 home_mailbox = .maildir/
94
95 dovecot_destination_recipient_limit = 1
96 virtual_transport = dovecot
97
98 smtpd_sasl_auth_enable = yes
99 smtpd_sasl_type = dovecot
100 smtpd_sasl_path = private/auth
101
102 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
103 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domain_maps.cf
104 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
105
106 smtpd_sender_restrictions=
107 reject_non_fqdn_sender
108
109 smtpd_reject_unlisted_sender = yes
110
111 smtpd_recipient_restrictions=
112 permit_mynetworks,
113 permit_sasl_authenticated,
114 reject_non_fqdn_recipient,
115 reject_unauth_destination,
116 check_policy_service inet:127.0.0.1:2501
117
118 smtpd_milters = unix:/var/run/dk-filter/dk-filter.sock,
119 unix:/var/run/dkim-filter/dkim-filter.sock, inet:localhost:8026
120 non_smtpd_milters = unix:/var/run/dk-filter/dk-filter.sock,
121 unix:/var/run/dkim-filter/dkim-filter.sock, inet:localhost:8026
122 inet_protocols = all
123 [cut]
124
125 As I basically followed the wiki, I have no idea if this config is
126 ordinary or not. :) Thanks again for your help.
127
128 Thanks,
129 Paul

Replies

Subject Author
Re: [gentoo-server] Postfix: Can I insert a custom header to incoming mail? kashani <kashani-list@××××××××.net>