From: Bernd Nies on
Hi,

Is it possible to rewrite an email address that contains invalid characters?

Example: Rewrite ":user(a)domain.com" to "user(a)domain.com" -- stripping
of the leading ":" (colon).

I read through the Postfix Address Rewriting README [1] but did not
find a hint. Source routing looks close but that's not it. Using
header_checks [2] with REDIRECT is also not very useful because I have
to create such an entry for every possible email address.

Background info: We're currently having a problem with Zimbra
Collaboration suite 6.0.5 and Thunderbird Lightning 1.0b1. Calendar
invitations from a customer contain an empty CN= field in the
organizer and attendee fields as follows:

ORGANIZER;CN=:MAILTO:organizer(a)exchangeuser.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=:MAILTO:bernd(a)zimbrauser.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=:MAILTO:otherguy(a)zimbrauser.com

The bug is, that when accepting/declining the calender, the email
parsing is wrong and wants to send an email to
:organizer(a)exchangeuser.com (yes, with the leading colon). This email
address is rejected on the customer's email server. I thought about
using Postfix on our outbound SMTP gateway for stripping off the
leading ":" from the destination address.


Thanks in advance.

Best regards,
Bernd


[1] http://www.postfix.org/ADDRESS_REWRITING_README.html
[2] http://www.postfix.org/header_checks.5.html

From: Wietse Venema on
Bernd Nies:
> Hi,
>
> Is it possible to rewrite an email address that contains invalid characters?
>
> Example: Rewrite ":user(a)domain.com" to "user(a)domain.com" -- stripping
> of the leading ":" (colon).
>
> I read through the Postfix Address Rewriting README [1] but did not
> find a hint.

Postfix address rewriting is based on table lookup, therefore you
can use any Postfix lookup table for address rewriting.

Documentation:
http://www.postfix.org/pcre_table.html
http://www.postfix.org/canonical.5.html

Example:
/etc/postfix/main.cf:
canonical_maps = pcre:/etc/postfix.canonical.pcre

/etc/postfix.canonical.pcre
/^:(.+@example\.com)$/ $1

Wietse