OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Rewrite with Pattern

From: Noel Jones (njonesmegan.vbhcs.org)
Date: Tue Dec 02 2008 - 17:43:28 CST


Fat Bear Mail Services wrote:
> Noel Jones wrote:
>> Fat Bear Mail Services wrote:
>>> How would one setup Postfix that uses /etc/passwd for authentication
>>> so that e-mails of the pattern:
>>>
>>> username-companyID-anyStringdomain1.com
>>>
>>> is delivered to:
>>>
>>> usernamecompanyDomain.com
>>>
>>> where there is a 1:1 mapping between companyID and companyDomain?
>>> For example:
>>>
>>> pat-acme-beta123mycompany.com >>> patacmedesign.com
>>>
>>> Note above that "acme" maps to "acmedesign.com".
>>
>> One would use an awk or perl script to generate a virtual_alias_map
>> from the input file.
> The virtual_alias_map could not be hash:/etc/postfix/virtual because
> that could not handle e-mail addresses where "anyString" is discarded,
> right? I would think that we'd need to have regexp:/etc/postfix/virtual
> that can handle transformations such as:

I'm glad to see you've done some homework before asking.
The point I'm making is that while you *can* use a regexp for
virtual_alias_maps, you shouldn't.

Whatever matches in virtual_alias_maps is considered a valid
address, so a regexp map is (usually) not appropriate. It's
important for postfix to know valid addresses so that invalid
ones can be rejected during SMTP - before they are accepted
and cause backscatter bounces.

So, as I said earlier, use awk or perl to generate a hash
table with the proper 1-1 transformations in it, using the
your password file as the data source. You can automate this
with a Makefile and cron so that a new table is periodically
rebuilt automatically, but only when there are changes.

If you think a regexp map is appropriate, explain why.

--
Noel Jones