[2025-01-15 15:16] Heinrich Rebehn <heinr...@rebehn.net>
> Hello all,
>
> I am trying to setup a mailing list server using OpenSmtpd using postgres 
> tables.
>
> My (stripped down) smtp.conf:
>
> ——————————————————————————————————————————
>      1        table domains postgres:/etc/mail/postgres.conf
>      2        table virtuals postgres:/etc/mail/postgres.conf
>      3        table senders postgres:/etc/mail/postgres.conf
>      4        #
>      5        listen on egress port 25
>      6        #
>      7        action "local" mbox alias <virtuals>
>      8        
>      9        match from mail-from <senders> for domain <domains> action 
> "local"
>
> -------------------------------------------
>
> postgres.conf:
>
>      1        conninfo host='localhost' user='mailman' password='mailman' 
> dbname='test'
>      2        query_alias         SELECT destination      FROM virtuals       
> WHERE email=$1;
>      3        query_credentials   SELECT email, password  FROM credentials    
> WHERE email=$1;
>      4        query_domain        SELECT domain           FROM domains        
> WHERE domain=$1;
>      5        query_mailaddr      SELECT email            FROM senders        
> WHERE alias=$1;
>
> ———————————————————————————————————
>
> The table definition:
>
> # psql -h localhost -U mailman test
> psql (16.4)
> Type "help" for help.
>
> test=> \d senders
>                                     Table "public.senders"
>  Column |          Type          | Collation | Nullable |               
> Default               
> --------+------------------------+-----------+----------+-------------------------------------
>  id     | integer                |           | not null | 
> nextval('senders_id_seq'::regclass)
>  alias  | character varying(255) |           |          | 
>  email  | character varying(255) |           |          | 
>
> —————————————————————
>
> When I try to start smtpd, I get:
>
> # smtpd -n
> /etc/mail/smtpd.conf:3: syntax error
> /etc/mail/smtpd.conf:9: syntax error
> warn: no rules, nothing to do
>
> ———————————————————————
>
> The error about line 9 ist ok, because the table declaration for <senders> 
> ist not accepted. But what is wrong with line 3?

You missinterpret the error at line 9, it's the same error as in
line 3. "senders" is a keyword so you can't use it as table name
without quotes.

> Also, how does /usr/local/libexec/smtpd/table-postgres know what postgres 
> table to select for the smtpd table ‘senders’?
> Where is the link between line 3 in smtpd.conf and line 5 in postgres.conf? 
> It seems that I am missing something here!

Depending where you use a table, different services of the table are
requested. So when opensmtpd needs a mailaddress from the table
it ask the service "mailaddr". The table can then look for matching
data acording to the config and the requested service. For details
look at smtpd-tables(7).

Because of this you don't need multible tables for this setup. smtpd
will send the correct requests to the table and table-postgres can
use the correct query.

Also you might want to use the senders option of "listen on" with the
mailaddrmap setting of table-postgres. So you can ``bind'' a mailaddress
to a specific user.

Philipp

>
> OpenBSD mail.rebehn.net 7.6 GENERIC.MP#338 amd64
> postgresql-server-16.4p0
>
> Thanks for any help,
>
> -Heinrich
>
>

Reply via email to