On Fri, Oct 25, 2024 at 12:39:50PM +0200, Thomas Landauer via Postfix-users wrote:
> > Rather, Postfix address rewriting makes multiple queries against > > whatever tables are configured, using various fragments of the input > > address as documented for virtual(5), aliases(5), canonical(5), etc. > > Sorry, I still don't get it :-( > If everything is tried anyway, then what's the reason of having `%s`, `%u` > and `%d` at all? > > And can these additional queries be disabled somehow? > > You're referring to this part at https://www.postfix.org/virtual.5.html - > right? > > > Each query pattern is sent to each specified lookup table before trying > > the next query pattern, until a match is found. > > I think you should repeat this info on > https://www.postfix.org/pgsql_table.5.html too, cause with this being my > setup in `main.cf`: > > > local_recipient_maps = pgsql:/etc/postfix/pgsql_local_recipient_map.cf > > ... I didn't look at virtual(5), aliases(5), canonical(5), cause those > didn't seem relevant. You should read and understand as much as possible of: http://www.postfix.org/ADDRESS_REWRITING_README.html http://www.postfix.org/DATABASE_README.html#intro and also https://www.postfix.org/postconf.5.html#local_recipient_maps https://www.postfix.org/LOCAL_RECIPIENT_README.html#format If you use local files in postmap(1) format, then local_recipient_maps expects the following table format: * In the left-hand side, specify a bare username, an "@domain.tld" wild-card, or specify a complete "u...@domain.tld" address. * You have to specify something on the right-hand side of the table, but the value is ignored by local_recipient_maps. If you use lookup tables based on NIS, LDAP, MYSQL, or PGSQL, then local_recipient_maps does the same queries as for local files in postmap(1) format, and expects the same results. With regular expression tables, Postfix only queries with the full recipient address, and not with the bare username or the "@domain.tld" wild-card. The above means that queries will be issued for: - The the full address - The bare username - "@domain" If locating the relevant records to answer these queries against your database schema requires you to use "%u" or "%d" rather than the verbatim lookup key, you're free to do so. You can also specify the "domain" parameter of the PostgresQL table, end they bare user lookups will never be issued, and only matching domains will be queried. > # About postgresql:// connection URI: > > You should explain that such URIs are parsed by Postgres (not Postfix) - > cause this is certainly not obvious for everybody. Then add a link to > https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING > (which indeed does explain it nicely), and that's it. I don't know why it is relevant which software parses the URI, but a link to the Postgres docs would certainly be reasonable. > In the example, use a string with as many parts as possible (password, > multiple options, etc.), cause for users it's always easier to delete stuff > than to find out how to append stuff. Feel free to share a more realistic example than my experiment with "postgresql:///dane", which works as written, because nothing else is needed for a default unix-domain socket connection. Neither Wietse nor I use a Postgres backend on our mailservers, so our experience with what's representative/useful in connection strings is very limited. The community of users who actually use Postgres DB tables are better positioned to provide realistic examples. -- Viktor. _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org