Re: OpenSMTP lmtp without unix users

2024-04-27 Thread Nicolas Goy
On Sat Apr 27, 2024 at 5:31 PM CEST, Nicolas Goy wrote:
>
> How can I make it work with a single vmail unix user? Without losing the
> catchall?

Ok, I finally figured it out with the answer I got.

I tried to use the rcpt-to flag in deliver in the smtpd.conf, but I always ended
with non existing users.

The thing is, in vusers, there must be alias to emails AND at the end, an alias
to the virtual user, like:

a...@example.com a...@example.com
@ m...@example.com
m...@example.com vmail
a...@example.com vmail

Then, rcpt-to must be added in the smtpd.conf, like so

  action deliver lmtp "/var/dovecot/lmtp" rcpt-to virtual 

Then dovecot will get emails with the full email address as username, but that
can easily be mapped to the correct folder with

  mail_home=/srv/mail/%Ln  # (%Ln insteand of %Lu)

Of course, the vusers table above will need to have different local part for all
users, but that's ok in my case.

-- 
Nicolas Goy
Developer and electronic engineer
Goyman SA

https://kuon.ch
https://goyman.com



Re: OpenSMTP lmtp without unix users

2024-04-27 Thread Kirill A . Korinsky
Greetings,

On Sat, 27 Apr 2024 17:31:24 +0200,
"Nicolas Goy"  wrote:
> 
> How can I make it work with a single vmail unix user? Without losing the
> catchall?
> 

I do have a bit more complicated setup.

smtpd.conf:

   table local-emails   file:/etc/mail/local-emails
   table aliasesfile:/etc/mail/aliases
   table domainsfile:/etc/mail/domains
   table credentialspasswd:/etc/mail/credentials

   ...

   listen on egress inet4 port smtp tls pki mx.catap.net \
  filter { admdscrub, "auth", dnsbl }

   action deliver_lmtp lmtp "/var/dovecot/lmtp" rcpt-to virtual 
   match from any for domain  \
 ! rcpt-to  action deliver_lmtp


so tables:

1. local-emails is a list of email which can be reached only inside mail
server. For example I like to have nice email for printer, but I don't like
when it start to recieve spam :)

2. credentials is shared with dovecot and has format:

  :::extra_fields

thus, usually I use short version:

  :::

where password is hash which I get via smtpctl encryp.

3. domains is just a list of supported domains. I don't really need it here,
but keep it because it is re-used inside DKIM signature generator.

4. alisases, it is usual alliases plus each user from credentials should
have record like:

  u...@email.com: vmail

to redirect his email to dovecot. No record here means user may send email
(auth on mail server) but never get anything back. And mail server says that
user do not exists which can be an issue for some servers.

-- 
wbr, Kirill



OpenSMTP lmtp without unix users

2024-04-27 Thread Nicolas Goy
Hello,

I have my OpenSMTP server configured as follow:

pki mx-pki cert   "xxx"
pki mx-pki key"xxx"

filter   "rdns" phase connect match   !rdns disconnect "550 DNS error"
filter "fcrdns" phase connect match !fcrdns disconnect "550 DNS error"
filter "rspamd" proc-exec "/usr/local/libexec/smtpd/filter-rspamd"
filter "rspamd-dkim" proc-exec "/usr/local/libexec/smtpd/filter-rspamd 
-settings-id dkim"

srs key "xxx"

table credsfile:/etc/mail/creds
table vdomsfile:/etc/mail/vdoms
table vusers   file:/etc/mail/vusers
table aliases  file:/etc/mail/aliases

# Inbound from external
listen on re0 tls pki mx-pki filter { "rdns", "fcrdns", "rspamd" }

# Run rspamd on outgoing for DKIM
listen on re0 port 587 tls pki mx-pki auth-optional  filter "rspamd-dkim"

action expand expand-only alias 
action deliver lmtp "/var/dovecot/lmtp" virtual 
action send relay helo  srs

match from local for local action expand
match from local !for domain  action send
match from any for domain  action deliver
match from auth for any action send
match from src 10.0.0.0/8 for any action send


Now, in vdom, I have a list of domain that I accept email for:

a.com
b.com
...

And in vusers, I have something like this:

exter...@a.com someth...@gmail.com
foo...@a.com foobar
@ kuon

Now this works, emails received for exter...@a.com are relayed back to 
someth...@gmail.com
and foo...@a.com is delivered to the foobar user and the rest to my user kuon.

The problem is that this requires the local users kuon and foobar.

How can I make it work with a single vmail unix user? Without losing the
catchall?

Thanks

-- 
Nicolas Goy
Developer and electronic engineer
Goyman SA

https://kuon.ch
https://goyman.com