Score:0

shared mail address with postfix and dovecot

tt flag

I'm trying to set up some shared mailboxes like contact or support.

I have made it possible for me to share an IMAP folder between users in Dovecot by doing this in 15-mailboxes.conf

namespace {
  type = shared
  separator = /
  prefix = Shared/
  location = mbox:/mail/shared
  subscriptions = no
  list = children
  mailbox support {
    auto = subscribe
  }
  mailbox contact {
    auto = subscribe
  }
}

and then I'm using ACL to control who has access to each folder.

I want to make the support and contact mail addresses public, so you can email them. But postfix keeps saying the users don't exist. I have made a file called /etc/postfix/virtualmaps and postmap it.

[email protected] support
[email protected] contact

And in my postfix main.cf, I have added this:

virtual_mailbox_base = /mail/shared
virtual_mailbox_maps = lmdb:/etc/postfix/virtualmaps

if I add virtual_mailbox_domains = $mydomain, postfix throws errors and says that mydestination and virtual_mailbox_domains cant be the same.

All users are ldap users

Edit 1

@NikitaKipriyanov has pointed me in the direction of local_recipient_maps and then I have found local_delivery that passes everything to dovecot.

It does still not work and but now its that dovecot can't find the ldap user

Edit 2

Docecot has building feature to share an IMAP inbox: https://doc.dovecot.org/configuration_manual/shared_mailboxes/#shared-mailboxes

here are som logs with local_recipient_maps active:

2023-07-17T14:18:21.117842+02:00 tst postfix/pickup[5200]: 1CA20213BC0: uid=0 from=<[email protected]>
2023-07-17T14:18:21.127591+02:00 tst postfix/cleanup[5212]: 1CA20213BC0: message-id=<64b5318d.5XutEBb44MdWM3yJ%[email protected]>
2023-07-17T14:18:21.167058+02:00 tst postfix/qmgr[5199]: 1CA20213BC0: from=<[email protected]>, size=449, nrcpt=1 (queue active)
2023-07-17T14:18:21.230250+02:00 tst postfix/local[5214]: 1CA20213BC0: to=<[email protected]>, relay=local, delay=0.13, delays=0.06/0.03/0/0.03, dsn=5.1.1, status=bounced (unknown user: "support")
2023-07-17T14:18:21.231069+02:00 tst postfix/cleanup[5212]: 38487213BC2: message-id=<[email protected]>
2023-07-17T14:18:21.233902+02:00 tst postfix/bounce[5215]: 1CA20213BC0: sender non-delivery notification: 38487213BC2
2023-07-17T14:18:21.233966+02:00 tst postfix/qmgr[5199]: 38487213BC2: from=<>, size=2226, nrcpt=1 (queue active)
2023-07-17T14:18:21.234323+02:00 tst postfix/qmgr[5199]: 1CA20213BC0: removed
2023-07-17T14:18:21.235893+02:00 tst postfix/local[5214]: 38487213BC2: to=<[email protected]>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)

And here are some logs with local_recipient_maps and local_delivery active:

2023-07-20T13:09:48.958737+02:00 tst postfix/qmgr[31655]: 274CA215D35: from=<[email protected]>, size=449, nrcpt=1 (queue active)
2023-07-20T13:09:48.993036+02:00 tst dovecot: lda([email protected])<31682><>: Debug: Loading modules from directory: /usr/lib64/dovecot/modules
2023-07-20T13:09:48.993428+02:00 tst dovecot: lda([email protected])<31682><>: Debug: Module loaded: /usr/lib64/dovecot/modules/lib01_acl_plugin.so
2023-07-20T13:09:48.993549+02:00 tst dovecot: lda([email protected])<31682><>: Debug: auth-master: userdb lookup([email protected]): Started userdb lookup
2023-07-20T13:09:48.993643+02:00 tst dovecot: lda([email protected])<31682><>: Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb: Connecting
2023-07-20T13:09:48.993756+02:00 tst dovecot: lda([email protected])<31682><>: Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb (pid=26599,uid=0): Client connected (fd=8)
2023-07-20T13:09:48.996561+02:00 tst dovecot: lda([email protected])<31682><>: Debug: auth-master: userdb lookup([email protected]): auth USER input:
2023-07-20T13:09:48.996672+02:00 tst dovecot: lda([email protected])<31682><>: Debug: auth-master: userdb lookup([email protected]): Userdb lookup failed
2023-07-20T13:09:48.996765+02:00 tst dovecot: lda(31682): Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb (pid=26599,uid=0): Disconnected: Connection closed (fd=8)
2023-07-20T13:09:49.003457+02:00 tst postfix/pipe[31681]: 274CA215D35: to=<[email protected]>, relay=dovecot, delay=903, delays=903/0.01/0/0.03, dsn=5.1.1, status=bounced (user unknown. Command output: lda([email protected]): Error: net_connect_unix(/var/run/dovecot//stats-writer) failed: Permission denied )
2023-07-20T13:09:49.009715+02:00 tst postfix/cleanup[31684]: 0233E215EBD: message-id=<[email protected]>
2023-07-20T13:09:49.012518+02:00 tst postfix/bounce[31683]: 274CA215D35: sender non-delivery notification: 0233E215EBD
2023-07-20T13:09:49.012577+02:00 tst postfix/qmgr[31655]: 0233E215EBD: from=<>, size=2430, nrcpt=1 (queue active)
2023-07-20T13:09:49.012611+02:00 tst postfix/qmgr[31655]: 274CA215D35: removed
2023-07-20T13:09:49.022166+02:00 tst dovecot: lda([email protected])<31685><>: Debug: Loading modules from directory: /usr/lib64/dovecot/modules
2023-07-20T13:09:49.022500+02:00 tst dovecot: lda([email protected])<31685><>: Debug: Module loaded: /usr/lib64/dovecot/modules/lib01_acl_plugin.so
2023-07-20T13:09:49.022610+02:00 tst dovecot: lda([email protected])<31685><>: Debug: auth-master: userdb lookup([email protected]): Started userdb lookup
2023-07-20T13:09:49.022700+02:00 tst dovecot: lda([email protected])<31685><>: Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb: Connecting
2023-07-20T13:09:49.022821+02:00 tst dovecot: lda([email protected])<31685><>: Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb (pid=26599,uid=0): Client connected (fd=8)
2023-07-20T13:09:49.025074+02:00 tst dovecot: lda([email protected])<31685><>: Debug: auth-master: userdb lookup([email protected]): auth USER input:
2023-07-20T13:09:49.025181+02:00 tst dovecot: lda([email protected])<31685><>: Debug: auth-master: userdb lookup([email protected]): Userdb lookup failed
2023-07-20T13:09:49.025271+02:00 tst dovecot: lda(31685): Debug: auth-master: conn unix:/var/run/dovecot//auth-userdb (pid=26599,uid=0): Disconnected: Connection closed (fd=8)
2023-07-20T13:09:49.027037+02:00 tst postfix/pipe[31681]: 0233E215EBD: to=<[email protected]>, relay=dovecot, delay=0.02, delays=0.01/0/0/0.01, dsn=5.1.1, status=bounced (user unknown. Command output: lda([email protected]): Error: net_connect_unix(/var/run/dovecot//stats-writer) failed: Permission denied )
2023-07-20T13:09:49.027394+02:00 tst postfix/qmgr[31655]: 0233E215EBD: removed
Nikita Kipriyanov avatar
za flag
All virtual_* settings are for virtual domains; that is, when a single Postfix instance is serving more than one mail domain, for example both "example.com" and "example.org" at the same time. If you don't have that, use mailbox_maps, your mailbox should appear there. Then, you need to make sure dovecot won't reject it but deliver into desired shared mailbox.
Kiwimarc avatar
tt flag
@NikitaKipriyanov I knew that virtual_mailbox_domains was to server multiple domains, but didn't know that it was possible to remove the virtual in the other settings. I have tried it: `mailbox_base = /mail/shared` `mailbox_maps = lmdb:/etc/postfix/virtualmaps` but now postfix says that the settings are unused?
Nikita Kipriyanov avatar
za flag
I was mistaken, the mailbox maps setting for domains in `mydestination` is called [`local_recipient_maps`](https://www.postfix.org/postconf.5.html#local_recipient_maps). This is where you add your additional addresses for Postfix to not reject mails to these addresses. Note that you can have *more than one* map assigned to *_maps setting and their results will be combined. Again, make sure Dovecot won't reject them too but deliver to proper mailbox.
Kiwimarc avatar
tt flag
@NikitaKipriyanov It still bounces with unknown user error. I have tried to play a little with local delivery, because it seems like dovecot never sees the mail before the bounce. But that didn't work either, maybe just because I'm setting it up wrong?
Nikita Kipriyanov avatar
za flag
If I knew a full answer I'd suggest it in the "answer" box. I never worked with Dovecot. Cyrus IMAP has a special syntax which allows you to post mail into shared mailbox or directly into non-INBOX of ordinary users with standard LMTP delivery agent; in that case, the mail address looks like "prefix+mailbox" where prefix is user name or, for shared mailboxes, is configured; also you need to add "post" permission on that mailbox to anyone. And, to route nice address like "support@domain" into such address, you set up an alias in Postfix. Maybe, Dovecot has similar mechanism?
Nikita Kipriyanov avatar
za flag
And, show logs! At least, Postfix logs, from which I will be able to say is that a problem on Postfix or Dovecot side.
Kiwimarc avatar
tt flag
@NikitaKipriyanov You are correct that logs are need, im sorry they weren't there at the time. Dovecot does have a buildin feature to share IMAP inboxes, with is working just fine. I have linked to how that is working. I have just made a shared namespace as shown in the post and then using ACL to control who has access
Score:0
tt flag

I have found a solution!

If I just use postfix alias feature, I can make postfix deliver it directly to the mailbox and not lookup if the "user" exist

So the way I did it was to update my alias file and added:

support /mail/shared/support
contact /mail/shared/contact

I will have to test if this means that I have bypassed spamassasin and the virus scanner. I will update this answer when I know that

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.