On Wed, Apr 21, 2010 at 10:32:36AM -0400, Phil Howard wrote:
Ideal would be a one-file solution, which can be managed by text editing or simple command line tools. But what I want is ONE file that both Postfix (for valid recipients) and Dovecot (for user login authentication) can use together. An alternative is some way to get Postfix to go through Dovecot to query for users (at the time of mail arriving on SMTP so it doesn't queue anything that would later be rejected). This is a smallish setup on one server, with probably a max of 50 to 100 users and 50 or so role account mailboxes over the next year or two. Any recommendations?
If you can't get postfix to read dovecot's virtual users, try switching to exim. I found exim can be configured to read pretty much any format you like. For example, I got exim to read courier-imap's userdb.dat files:
# Lookup in userdb. If the address lookup succeeds, then we set # address_data. If it's forced to fail, we'll drop through to the next # router. If a temporary error occurs (e.g. file not readable), we'll defer.
reset_address_data: driver = redirect address_data = data =
userdb_lookup:
driver = redirect
condition = ${if ! def:address_data}
address_data = source=userdb ${sg
{${lookup {$local_part@$domain} dbmnz {/path/to/userdb.dat} {$value}
{${lookup {@$domain} dbmnz {/path/to/userdb.dat}
{$value} fail }} }}
{([^=]+)=([^|]+)\\|?} {\$1=\${quote:\$2\} } }
# note space between \$2\} and the next }
data =
Then use ${extract {home} {$address_data} ...} to get field "home" from the userdb entry.
Basically what it's doing is finding the the .dat entry with key user@domain or @domain (wildcard), finding a value of the form foo=bar|baz=qux and rewriting it to foo="bar" baz="qux", which the ${extract} function expects.
This sort of coding in exim's configure file is not pretty, but it works well.
With only 50-100 users you'd be fine with a plain text file rather (lsearch) than a .dat
HTH,
Brian.