0

On the mail server I have been trying to set up, I've configured postfix to deliver mail to the virtual user user1 (with email address user1@example.com) to the file /var/mail/vhosts/user1@example.com/mail. I did this by setting:

# /etc/postfix/main.cfg
virtual_mailbox_maps = mysql:/etc/postfix/virtmailmaps.conf

and:

# /etc/postfix/virtmailmaps.conf
# ...
query = SELECT destination FROM virtusers WHERE email='%s'

The mysql database has the virtusers table:

+----+----------+-------------------+------------------------+
| id | password |        email      |      destination       |
+----+----------+-------------------+------------------------+
|  1 | ...      | user1@example.com | user1@example.com/mail |
+----+----------+-------------------+------------------------+

Now, for dovecot I have set:

mail_location = mbox:/var/mail/vhosts:INBOX=/var/mail/vhosts/%u/mail

and:

password_query = SELECT email as user, password FROM virtusers WHERE email='%u';

This I clearly hacked together to work, but when I access squirrelmail and send/delete emails, the folders Drafts, Trash and Sent are created in /var/mail/vhosts and its contents are shared between all the virtual users.

So, it seems I haven't set some home option correctly, but I don't quite clearly understand what the configuration file options are doing (in postfix, dovecot and squirrelmail) and how it all meshes together. For example, I have already set:

# /etc/dovecot/conf.d/auth-sql.conf.ext
userdb {
  driver = static
  args = uid=vmail gid=vmail home=/var/mail/vhosts/%u
}

How do I fix this so that the Drafts, Trash and Sent directories are in each user's home directory /var/mail/vhosts/user1@example.com/?

0

Shouldn't you have

mail_location = mbox:/var/mail/vhosts/%u:INBOX=/var/mail/vhosts/%u/mail

i.e. you don't currently have the username %u variable in the mbox path, only in the INBOX path.

  • Ah! Is that it. I remember trying that before and it not working so maybe I made a mistake. I've currently switched to maildir format so I can't confirm this yet, but thanks! – Zorawar Mar 11 '18 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.