Glenn Steen glenn.steen at gmail.com
Wed Dec 13 08:43:15 GMT 2006

On 12/12/06, Matt Kettler <mkettler at evi-inc.com> wrote:
> Peter Russell wrote:
> > I have postfix recipient maps and some one on here once helped me format
> > the content using regexp so i could create one entry that covered
> > multiple formats. I need to change that but am almost clueless as to how.
> >
> > Could some one offer a suggestion on how to write the following as a
> > regexp.
> >
> > Current                Required
> > user at domain.com    OK        user at domain.com        OK
> >                 user at domain.com.au    OK
> >
> > Is the REGEXP something like
> > /user at domain/.[com|/.com/.au]    OK
> Disclaimer: I know regexes VERY well, but postfix not at all.
Well, I'll comment on the postfix side then:-). ISTR I was the one
helping Pete out last time:-).
> Provided there's not some weirdness in postfix that forces regexes
> to match full-text, you can simplify further to:
No "weirdness" to talk about. Postfix supports both POSIX regexps and
Perl compatible regexps ("man regexp_table pcre_table" shows the
difference in the postfix config, "man [5|7] regex" or "man 7
re_format" (or similar, depending on OS) documents POSIX REs, while
the usual perl docs on REs document the pcre part).
In an access type file, one needs to remember that when using REs,
postfix will not do the "magic exploding" of the address into its
constituent parts (local/domain etc), but other than that... No real
weirdness at all;-).

> 6) If the substring matching pointed out in 5 is over-broad for you, you can fix
> 4 by ending anchors for beginning and end of input:
> /^user at domain\.com(\.au)?$/
> That will only match exactly "user at domain.com" or "user at domain.com.au"

This is the one I'd recommend you to use Pete.
Keep in mind that although the RE tables are easier to maintain, the
indexed ones are faster, and have some "magic" to make rules based on
part(s) of the address. I wont deny that it'd be a two-line thing for
this case, though... If you generate them with a script (and the set
is fairly huge), you'd perhaps best try and time lookups on the
different table types as described in the respective man pages ("less
/etc/postfix/access" should contain the info on a regular indexed
access file).

Other than that... You'll be very well off with Matts (excellently
explained) RE above.

-- Glenn
email: glenn < dot > steen < at > gmail < dot > com
work: glenn < dot > steen < at > ap1 < dot > se

More information about the MailScanner mailing list