This is one possible configuration which should do that which I think you are describing:

-------------------------------------------------------------------------

table vdomains   file:/etc/mail/table_vmail_domains
table vaddr          file:/etc/mail/table_vmail_addresses
table vmailstub   { '@' = vmail }

action "deliver_vmail" maildir "/home/vmail/domains/%{rcpt.domain:lowercase}/%{rcpt.user:lowercase|strip}" virtual <vmailstub>

match from any for domain <vdomains> rcpt-to <vaddr> action "deliver_vmail"

-------------------------------------------------------------------------

This setup accepts mail ONLY for virtual accounts and delivers it to a typical "vpopmail" maildir structure: "/home/vmail/domain/name"

You must create a system user "vmail" which does not receive any mail but is just the home folder for the mailboxes and the user for permission to deliver the mail.

Automate making the domains file with a script which extracts the unique domains from the addresses file.  The redundancy here is due to the smtpd.conf requirements (i.e. not because I think it's cool to have both domain and email address files).

If it's not clear, I can elaborate on how it works.


-Andy



On 4/5/2020 4:24 AM, Leo Unglaub wrote:
Hey,
first of all i want to thank you all for your work on OpenSMTPD over all those years. It has powered my one domain very well over all those years. But now i have a problem with setting up virtual domains and users.

My goal is the following. I have the following domains:

foo.com
bar.com

With those domains i have the following email addresses:

us...@foo.com
us...@foo.com
us...@bar.com
us...@bar.com

But all those users dont exist on my machine as real users. I just want to recieve emails for those accounts and process them via lmtp to dovecot. So my action basically looks like that:

action "local_lmtp_deliver" lmtp "/var/dovecot/lmtp"

But when i trace the lookup from the smtpd i get the following:

b4e62ea90ed6c91d smtp connected address=local host=foo.com
lookup: match "local" as NETADDR in table static:<anyhost> -> true
lookup: match "foo.com" as DOMAIN in table static:<anydestination> -> true
rule #1 matched: match from any for any action local_lmtp_deliver
lookup: lookup "user1" as USERINFO in table getpwnam:<getpwnam> -> none
b4e62ea90ed6c91d smtp failed-command command="RCPT TO:<us...@foo.com> " result="550 Invalid recipient: <us...@foo.com>"      b4e62ea90ed6c91d smtp disconnected reason=disconnect
debug: control -> client: pipe closed
debug: clearing p=client, fd=11, pid=0

For some reason the user1 part is still getting resolved as a real user on the system. I read on the man page and found the "user username" option for the action. I did the following:

action "local_lmtp_deliver" lmtp "/var/dovecot/lmtp" rcpt-to user "dovecot-worker"
dovecot-worker is the account used by dovecot to handle all the email storage in /var/vmail. But i get the same error.

So i guess i am doing it all wrong. Could someone please be so kind and give me a hint in the right direction how the virtual user stuff is working in OpenSMTPD. Because i think i am lost here. I am doing something completely wrong.

I am on the latest OpenBSD release (including all syspatch).

Thanks so much!
Greetings
Leo


Reply via email to