Discussion:
virtual_alias_maps and X-Original-To
(too old to reply)
Adam Hamer
2011-02-17 17:03:04 UTC
Permalink
I have an entry in the virtual_alias_maps for a few users to be redirected to zendesk.com. zendesk requires a X-Original-To header set for some stuff to work, but it isn't added in my postfix setup.
I have a basic postfix setup with dovecot for virtual delivery, but from the logs it appears dovecot is not instantiated when using virtual_alias_maps since the alias means its forwarded - because its an smtp task?    It seems to make sense from this thread that       [http://www.dovecot.org/list/dovecot/2011-January/056783.html]       "postfix adds X-Original-To when delivering to a mailbox - which delivery via smtp/lmtp isn't.",    and this one       http://tech.groups.yahoo.com/group/postfix-users/message/231881       "Postfix will not add X-Original-To when forwarding mail."
It seems filters were suggested to be used, but it doesn't seem a common approach. I'd appreciate some guidance on this - I am a newbie trying hard not to get too lost...
Regards,adam
Victor Duchovni
2011-02-17 18:16:28 UTC
Permalink
Post by Adam Hamer
I have an entry in the virtual_alias_maps for a few users to be
redirected to zendesk.com. zendesk requires a X-Original-To header set
for some stuff to work, but it isn't added in my postfix setup.
I have a basic postfix setup with dovecot for virtual delivery,
but from the logs it appears dovecot is not instantiated when using
virtual_alias_maps since the alias means its forwarded - because its
an smtp task???
No, the aliasing is not the crux of the issue when the resulting recipient
is still delivered locally, but see below.
Post by Adam Hamer
http://www.dovecot.org/list/dovecot/2011-January/056783.html
"postfix adds X-Original-To when delivering to a mailbox
- which delivery via smtp/lmtp isn't.",
This is right, only the local(8), virtual(8) and pipe(8) (flag-dependent)
prepend X-Original-To. The smtp(8) and lmtp(8) delivery agents do not
prepend X-Original-To headers.
Post by Adam Hamer
http://tech.groups.yahoo.com/group/postfix-users/message/231881
"Postfix will not add X-Original-To when forwarding mail."
Yes, really when not using a delivery agent that is typically used for
outbound or relay email. In the case of lmtp(8) this should perhaps be
revisited at some point.
Post by Adam Hamer
It seems filters were suggested to be used, but it doesn't seem a
common approach. I'd appreciate some guidance on this - I am a newbie
trying hard not to get too lost...
Are you in fact forwarding email off-site or are you using lmtp(8) to
deliver email into a Dovecot IMAP store?
--
Viktor.
Adam Hamer
2011-02-17 21:43:05 UTC
Permalink
Post by Victor Duchovni
Post by Adam Hamer
I have an entry in the virtual_alias_maps for a few users to be
redirected to zendesk.com. zendesk requires a X-Original-To header set
for some stuff to work, but it isn't added in my postfix setup.
I have a basic postfix setup with dovecot for virtual delivery,
but from the logs it appears dovecot is not instantiated when using
virtual_alias_maps since the alias means its forwarded - because its
an smtp task???
No, the aliasing is not the crux of the issue when the resulting recipient
is still delivered locally, but see below.
Post by Adam Hamer
http://www.dovecot.org/list/dovecot/2011-January/056783.html
"postfix adds X-Original-To when delivering to a mailbox
- which delivery via smtp/lmtp isn't.",
This is right, only the local(8), virtual(8) and pipe(8) (flag-dependent)
prepend X-Original-To. The smtp(8) and lmtp(8) delivery agents do not
prepend X-Original-To headers.
Post by Adam Hamer
http://tech.groups.yahoo.com/group/postfix-users/message/231881
"Postfix will not add X-Original-To when forwarding mail."
Yes, really when not using a delivery agent that is typically used for
outbound or relay email. In the case of lmtp(8) this should perhaps be
revisited at some point.
 
So my alias is outbound mail - I don't use lmtp (sorry - should have clarified that).
Post by Victor Duchovni
Post by Adam Hamer
It seems filters were suggested to be used, but it doesn't seem a
common approach. I'd appreciate some guidance on this - I am a newbie
trying hard not to get too lost...
Are you in fact forwarding email off-site or are you using lmtp(8) to
deliver email into a Dovecot IMAP store?
Off-site. Any ideas for which way to go to make those aliases have the X-Original-To?  
Post by Victor Duchovni
--
Viktor.
Thanks,adam
Victor Duchovni
2011-02-17 22:28:10 UTC
Permalink
Post by Adam Hamer
Post by Victor Duchovni
Are you in fact forwarding email off-site or are you using lmtp(8) to
deliver email into a Dovecot IMAP store?
Off-site. Any ideas for which way to go to make those aliases have
the X-Original-To?
Aliasing via virtual(5) is brutally efficient. No content modification,
just message routing, so the header is not added.

To add an X-Original-Recipient header, messages to multiple recipients
have to be split into one copy per-recipient since the header you want
is recipient-specific.

Since the queue file contains a single copy of the message for all
recipients, such rewriting *cannot* happen on input, it can only happen on
output via a delivery agent that is processing a single recipient. This
means you need a custom transport for this destination that processes
mail one recipient at a time and prepends the header.

This can be done via an external program via pipe(8) or by modifying the
source code of the smtp(8) delivery agent so that the header is added when
a suitable boolean flag is set and the message has exactly one recipient.

The pipe(8) approach would then re-submit the mail for outbound delivery
to a different Postfix instance to avoid loops.
--
Viktor.
Adam Hamer
2011-02-18 09:08:04 UTC
Permalink
Post by Victor Duchovni
Aliasing via virtual(5) is brutally efficient. No content modification,
just message routing, so the header is not added.
To add an X-Original-Recipient header, messages to multiple recipients
have to be split into one copy per-recipient since the header you want
is recipient-specific.
Since the queue file contains a single copy of the message for all
recipients, such rewriting *cannot* happen on input, it can only happen on
output via a delivery agent that is processing a single recipient. This
means you need a custom transport for this destination that processes
mail one recipient at a time and prepends the header.
This can be done via an external program via pipe(8) or by modifying the
source code of the smtp(8) delivery agent so that the header is added when
a suitable boolean flag is set and the message has exactly one recipient.
The pipe(8) approach would then re-submit the mail for outbound delivery
to a different Postfix instance to avoid loops.
--
Viktor.
  Thanks again Viktor.
It sounds a bit more in depth than I was hoping for. Given the _only_ function for this alias is to forward to one address, would it be possible to do a simpler approach? 
Regards, adam
Wietse Venema
2011-02-18 14:07:26 UTC
Permalink
Adam Hamer:
[ Charset ISO-8859-1 unsupported, converting... ]
Post by Victor Duchovni
Aliasing via virtual(5) is brutally efficient. No content modification,
just message routing, so the header is not added.
To add an X-Original-Recipient header, messages to multiple recipients
have to be split into one copy per-recipient since the header you want
is recipient-specific.
Since the queue file contains a single copy of the message for all
recipients, such rewriting *cannot* happen on input, it can only happen on
output via a delivery agent that is processing a single recipient. This
means you need a custom transport for this destination that processes
mail one recipient at a time and prepends the header.
This can be done via an external program via pipe(8) or by modifying the
source code of the smtp(8) delivery agent so that the header is added when
a suitable boolean flag is set and the message has exactly one recipient.
The pipe(8) approach would then re-submit the mail for outbound delivery
to a different Postfix instance to avoid loops.
--
Viktor.
??Thanks again Viktor.
It sounds a bit more in depth than I was hoping for. Given the _only_ func
-tion for this alias is to forward to one address, would it be possible to do
- a simpler approach??
If it is only for one special case,

/etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks
...
reject_unauth_destination
...
check_recipient_access hash:/etc/postfix/recipient_access

/etc/postfix/recipient_access:
***@example.com PREPEND: X-Original-To: ***@example.com

If it is for EXIM emulation:

/etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks
...
reject_unauth_destination
...
check_recipient_access pcre:/etc/postfix/recipient_access.pcre

/etc/postfix/recipient_access.pcre:
/(.+)/ PREPEND: X-Envelope-To: $1

Either way, if mail has multiple recipients, then they will see
the prepended message header.

Wietse
Wietse Venema
2011-02-18 14:16:19 UTC
Permalink
Post by Wietse Venema
??Thanks again Viktor.
It sounds a bit more in depth than I was hoping for. Given the _only_ func
-tion for this alias is to forward to one address, would it be possible to do
- a simpler approach??
If it is only for one special case,
/etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks
...
reject_unauth_destination
...
check_recipient_access hash:/etc/postfix/recipient_access
/etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks
...
reject_unauth_destination
...
check_recipient_access pcre:/etc/postfix/recipient_access.pcre
/(.+)/ PREPEND: X-Envelope-To: $1
Either way, if mail has multiple recipients, then they will see
the prepended message header.
Perhaps you want to place the check_recipient_access before the
permit_mynetworks, so that the header is also prepended applies
when local client send mail.

Wietse
Adam Hamer
2011-02-20 15:03:22 UTC
Permalink
Wietse Venema:>> If it is only for one special case,
/etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks
...
reject_unauth_destination
...
check_recipient_access hash:/etc/postfix/recipient_access
Post by Wietse Venema
Wietse
Just wanted to say thank you for the info. It turned out I needed "PREPEND" not "PREPEND:" (so, without the colon) - perhaps a different version or something, but it works!
Thanks,adam
Charles Marcus
2011-03-01 19:50:56 UTC
Permalink
Post by Victor Duchovni
Post by Adam Hamer
"Postfix will not add X-Original-To when forwarding mail."
Yes, really when not using a delivery agent that is typically used
for outbound or relay email. In the case of lmtp(8) this should
perhaps be revisited at some point.
Just to make sure I understand this correctly...

Currently, using virtual for deliver, I'm getting these X-Original-To
headers, which I have gotten very used to and rely on - but if/when we
switch to dovecot+LMTP, we will lose them?

If so, that is a show-stopper for me... also, what are the chances of
this being 'revisited' at any point in the foreseeable future?

Last - am I correct that we will *not* lose them if we just use the
dovecot LDA as opposed to LMTP?

Thanks,
--
Best regards,

Charles
Wietse Venema
2011-03-01 20:35:43 UTC
Permalink
Post by Charles Marcus
Post by Victor Duchovni
Post by Adam Hamer
"Postfix will not add X-Original-To when forwarding mail."
Yes, really when not using a delivery agent that is typically used
for outbound or relay email. In the case of lmtp(8) this should
perhaps be revisited at some point.
Just to make sure I understand this correctly...
Currently, using virtual for deliver, I'm getting these X-Original-To
headers, which I have gotten very used to and rely on - but if/when we
switch to dovecot+LMTP, we will lose them?
You can fake it in the SMTP server with

/etc/postfix/main.cf:
smtpd_recipient_restrictions =
check_recipient_access pcre:/etc/postfix/recipient_access.pcre

/etc/postfix/recipient_access.pcre
/(.+)/ prepend X-Original-To: $1

At a minor loss of privacy (plus that it would prepend
multiple headers in the case of multi-recipient mail).
Post by Charles Marcus
If so, that is a show-stopper for me... also, what are the chances of
this being 'revisited' at any point in the foreseeable future?
Last - am I correct that we will *not* lose them if we just use the
dovecot LDA as opposed to LMTP?
The chances depend on available time. Implementing one thing means
delaying another.

Wietse
Charles Marcus
2011-03-01 20:42:21 UTC
Permalink
Post by Wietse Venema
Post by Charles Marcus
Currently, using virtual for deliver, I'm getting these X-Original-To
headers, which I have gotten very used to and rely on - but if/when we
switch to dovecot+LMTP, we will lose them?
You can fake it in the SMTP server with
<snip>
Post by Wietse Venema
At a minor loss of privacy (plus that it would prepend
multiple headers in the case of multi-recipient mail).
Thanks very much for the workaround... I'll experiment and see if the
privacy implications are anything we should worry about (most people
don't even know what headers are, much less how to look at them, so
probably not a big deal)...
Post by Wietse Venema
Post by Charles Marcus
If so, that is a show-stopper for me... also, what are the chances of
this being 'revisited' at any point in the foreseeable future?
The chances depend on available time. Implementing one thing means
delaying another.
Understood... hopefully it is at least on a To-Do somewhere so it won't
get lost in the shuffle.

Thanks again Wietse!
--
Best regards,

Charles
Loading...