I tried to add to my postfix mail server the auto alias behavior that is used by Gmail, which can be summarized by tne rule Ignore all dots.

I found this article, which seemed to work with this pattern :

/^(.*)\.(.*)@(.*)$/ ${1}${2}@${3}

But when I found that it rewrites not only incoming mails but also outgoing ones (removing dots from foreign domains mail addresses, which may prevent mails to be delivered), Also, it only remove one dot. Useful for cases like surname.name, but we may encounter more than one dot. I wanted to improve that.

Currently, i use this line to rewrite emails in canonical form :

/^(([^.]*)\.)? ... ([^.]*)@((.*\.)*DOMAIN\.TLD)$/    ${2} ... ${N*2 + 1}@${N*2 + 2}

With :

  • N a arbitrary chosen number of dots
  • The sequence ([^.]*)\.)? repeated N times in the match pattern
  • The variables ${n*2} repeated N times in the rewrite pattern

(The last group is used to match the main domain or any of the sub-domains)

The current solution works, but :

  • It is capped to a chosen maximum of dots (but it is true that adding 100 dots to a regular mail address may be uncommon)
  • It is very ugly and difficult to read in configuration files (but it is true that config files may not be read everyday).

My question is : Is it possible to write a regexp for the postfix configuration (with only one step of rewriting and the whole address in input) to handle any number of dots ? Or what better workaround can I use to fulfill my objective ?

1 Answer 1


I found a way to do the job much simpler :

/^(.*)\.(.*)@((.*\.)*DOMAIN\.TLD)$/ ${1}${2}@${3}

It looks like that in postfix configuration, the patterns are tested against emails as many time as possible. So this pattern will match any time needed to remove all dots.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.