# Virtual Mailbox Delivery with Fetchmail & Postfix {SOLVED}

## faceman

I'm trying to set up a mail server which downloads mail from several addresses on different domains and makes them available via IMAP to the network so that any user can access any of the email accounts.  However, the accounts must remain separate for several reasons.  Therefore, I'm trying to set up virtual mailboxes. I can't get it to work.

I'm using fetcmail (which seems to be working, but should I run this as the user, or root?)  and postfix.  I'm pretty sure I can get the IMAP server to work, the problem is Postfix right now.

I have set up a vmail directory for the basedir called /home/vmail and populated it with domains and users like this:

```
/home/vmail/domain1.com/user1

/home/vmail/domain1.com/user2

/home/vmail/domain2.com/user3

/home/vmail/domain2.com/user4
```

here's my main.cf as per the docs:

```

virtual_mailbox_domains = domain1.com domain2.com

virtual_mailbox_base = /home/vmail

virtual_mailbox_maps = hash:/home/vmail/vmailbox

virtual_minimum_uid = 100

virtual_uid_maps = static:5000

virtual_gid_maps = static:5000

virtual_alias_maps = hash:/home/vmail/virtual

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

myhostname = myhost.mydomain

mydomain = mydomain

inet_interfaces = $myhostname, localhost

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

    xxgdb $daemon_directory/$process_name $process_id & sleep 5

newaliases_path = /usr/bin/newaliases

setgid_group = postdrop

```

/home/vmail/vmailbox:

```

user1@domain1.com      domain1.com/user1

user2@domain1.com      domain1.com/user2

user3@domain2.com      domain2.com/user3

user4@domain2.com      domain2.com/user4

```

and my .fetchmailrc

```

poll mail.domain1.com proto pop3 user "user1" password "pass1" keep

poll mail.domain1.com proto pop3 user "user2" password "pass1" keep

poll mail.domain2.com proto pop3 user "user3" password "pass1" keep

poll mail.domain2.com proto pop3 user "user4" password "pass1" keep

```

Fetchmail downloads messages, but I don't know where it puts them!  They're not in the root directory, or the user's directory, or in the mail spool.

----------

## magic919

Okay.  Fetchmail gets the mail and passes it to Postfix.  What do your mail logs say?  You should see what Postfix is doing with the email.

----------

## faceman

I figured it out.  I needed to change my .fetchmailrc to direct the mail to the virtual user.  I had tried directing it to nobody (as above) and to the user "vmail", but neither worked.  And the 55,983,345 pages of documentation I read didn't seem to mention anything of the sort, but it makes sense.

So the fetchmail entry should be something like:

```

poll mail.domain1.com proto pop3 user "user1" password "pass1" is "user1@domain1.com" here keep 
```

Since I used my full email address as the username, that's what it is for me.  Anyway, it should match the username in the "virtual_mailbox_maps" hash, then it will deliver directly to the specified directory.

----------

