Hello everyone!

I'm currently trying to setup OpenSMTPD 6.4 on alpine linux (edge) based on 
Hugo Barrera's guide on 
https://hugo.barrera.io/journal/2015/02/15/opensmtpd-dovecot-shared-sql-db/.

After some struggling I got everything up and running except for using senders 
in a listen directive to restrict user from sending mail from addresses they 
are not expected to send from. When I use

smtpd.conf:
...
table senderalias file:/etc/opensmtpd/senderalias.txt
...
listen on eth0 inet4 port submission tls-require pki mypki auth <credentials> 
senders <senderalias>
...

/etc/opensmtpd/senderalias.txt:
u...@example.com  al...@example.com,t...@example.com

everything works as expected. But as soon as I switch over to sqlite it fails. 
My sqlite config looks like this:

smtpd.conf:
...
table senderalias sqlite:/etc/opensmtpd/sqlite_senderalias.conf
listen on eth0 inet4 port submission tls-require pki mypki auth <credentials> 
senders <senderalias>
...

/etc/opensmtpd/sqlite_senderalias.conf:
dbpath                  /etc/opensmtpd/mail.sqlite
query_alias             SELECT (username||'@'||domain) FROM users WHERE ? LIKE 
mailbox AND enabled = 1;
query_mailaddr          SELECT (username||'@'||domain) FROM users WHERE ? LIKE 
mailbox AND enabled = 1;

When trying to deliver a mail I receive the following error in the smtpd logs:

lookup: lookup "u...@example.com" as MAILADDRMAP in table proc:senderalias -> -1
warn: failure during mailaddrmap lookup senderalias:u...@exampe.com

Afterwards the mail is rejected with error 421 Temporary error. Running the SQL 
queries manually by replacing the ? with u...@example.com returns the expected 
addresses.

My sqlite database looks similar to the one from the guide. I just added a few 
fields e.g. enabled and sendonly:

CREATE TABLE "users" (
"username" TEXT NOT NULL,
"domain" TEXT NOT NULL,
"mailbox" TEXT,
"enabled" INTEGER NOT NULL DEFAULT 1,
"password" TEXT,
"sendonly" INTEGER NOT NULL DEFAULT 0
);

Can anyone give me a hint on what I'm missing?

Greetings,
  Michael

Reply via email to