# Virtual Mailhosting System with Postfix Guide

## ragarwal

http://www.gentoo.org/doc/en/virt-mail-howto.xml

This guid is so screwed up that it is beyond belief that it is still up on Gentoo Forums.   :Sad:   :Sad: 

Spent countless number of hours fighting with this thing!!!! UUUUFFF.. I give up.

Is there a kind soul who could work with me on updating this documentation?  I'd be willing to provide my experience and time to update it.  I don't conplete understand all of postfix yet, so I need some guidance (minimal).

Thanks,

-Raj

----------

## steveb

I am willing to help you. What do you want to change?

----------

## tomxaak

the first problem is that the courier daemon is now using authlib, not authdaemon

----------

## steveb

 *tomxaak wrote:*   

> the first problem is that the courier daemon is now using authlib, not authdaemon

 

Okay. I don't see this as a very big issue. Anyway... Only section 10.2 needs to be changed. If you compare, then you will see that the change is very minimal:

 *Code Listing 10.2 wrote:*   

> Next, we need to edit courier's authentication config's. 
> 
> Code Listing 10.2: Configuring authentication
> 
> ```
> ...

 

cheers

SteveB

----------

## tomxaak

yes, this is exactly what I've already changed

btw. newer version of the howto can be found here:

http://www.etherpunk.com/node/232

but following these instructions, comparing with both

howtos, i got this problem:

<1000@mail.domainxyz.tld> (expanded from <myusername@domainxyz.tld>): unknown user: "1000"

1000 is uid of myusername. But this is the opposite of virtual hosts, no? 

advantage of virtual hosts is in omitting usage of uids.

configuration files are set just like in the howto.

In the database I've:

id            1

email       myusername@domainxyz.tld

clear        somepassword

name       blablabla local user

uid           1000

gid           100

homedir     /home/vmail/domainxyz.tld/myusername

maildir       /home/vmail/domainxyz.tld/myusername/.maildir

quota

postfix       y

(domainxyz.tld and mail.domainxyz.tld have been replaced with valid domain with valid mx record of course and

myusername is valid system account with uid 1000 and gid 100)

tail /var/log/mail/current

May  3 23:44:40 [postfix/pickup] 71DF476B3A: uid=0 from=<root>

May  3 23:44:40 [postfix/cleanup] 71DF476B3A: message-id=<20050503214440.GA4522@myhostname.domainxyz.tld>

May  3 23:44:40 [postfix/qmgr] 71DF476B3A: from=<root@mail.domainxyz.tld>, size=391, nrcpt=1 (queue active)

May  3 23:44:40 [postfix/local] 71DF476B3A: to=<1000@mail.domainxyz.tld>, orig_to=<myusername@domainxyz.tld>, relay=local, delay=0, status=bounced (unknown user: "1000")

May  3 23:44:40 [postfix/qmgr] 71DF476B3A: removed

----------

## predisposition

steveb: thank you! I was trying to ask the same question earlier but didn't phrase it right -- this change helps me a ton!

----------

## predisposition

tomxaak...

my set up is now working. Thanks for the link to the newer version of the tutorial -- that one has some better explanations... I have some questions for you regarding your last post... 

-is this example user a virtual user? If so, is 1000 the vmail user id?

-in the maildir field you need a slash at the end: maildir /home/vmail/domainxyz.tld/myusername/.maildir/

-in addition to the mail log, check the  /var/log/mail.err log to make sure that a proper connection is being made to the database -- I was getting the unknown user error for a while, then I realized I had a typo in my pam_mysql config files that was screwing up the db connection

These are just thoughts -- hth

Sam

----------

## tomxaak

in fact, I've tried both cases,

existing valid system user and virtual user.

in the case of virtual user:

1) 1000 is the uid of user vmail

2) slash at the end of the path, fixed, nothing has been changed

3) the connection to the db must be working because the system was able to translate the myusername@domainxyz.tld to 1000@dmainxyz.tld, and only record that myusername is mapped to the uid 1000 is in the db

in the case of existing valid system user:

1) 1000 is the uid of system user, not vmail user

2) ..

3) ..

----------

## predisposition

is 1000 just a made up number here for example's sake? I'm confused how the system user and the vmail user could both have the same uid... Are there any messages at all in the mail error log?

----------

## tomxaak

given uids have been generated only for this example of course, in real they are different.

system users have different uid than vmail user. uids of virtual users are mapped to vmail user.

log:

May  5 16:39:50 [postfix/pickup] 52DCB76B3A: uid=0 from=<root>

May  5 16:39:50 [postfix/qmgr] 52DCB76B3A: from=<root@mail.domainxyz.tld>, size=387, nrcpt=1 (queue active)

May  5 16:39:50 [postfix/local] 52DCB76B3A: to=<1000@mail.domainxyz.tld>, orig_to=<myusername@domainxyz.tld>, relay=local, delay=0, status=bounced (unknown user: "1000")

May  5 16:39:50 [postfix/qmgr] 52DCB76B3A: removed

thats all I've in the log related to this email.

Postfix is trying to translate myusername to uid, and that is what I don't understand yet.

----------

## predisposition

What do you have in the other mysql tables (besides user)? Is there something in the relocated or virtual table that could be causing this? Also, are you sure the fields are properly identified in the the /etc/postfix/mysql* files? In my set up, I don't have anything in the virtual or relocated tables... I've got three domains. They are all identified as "virtual:" in the transport table, one of my users does have system account, two other test accounts do not and they each work fine. I'm just trying to think what might be different from your installation and mine... do you have separate mail logs? On my system there is "mail.log", "mail.info", "mail.err" and "mail.warn" -- all in /var/log/ -- the useful stuff for me is in mail.err

----------

## tomxaak

solved, my mistake

this was the problem (lame):

mysql-virtual.cf:select_field    = uid

instead of

mysql-virtual.cf:select_field    = destination

too many configuration files, I've checked all of them for 3 times at least, but this typo..

It was good at least for "forced" understading of how it works,

not just copy&paste from the howto  :Smile: 

anyway tnx for your time & support

----------

## o5gmmob8

Hi guys,

I am running postfix and everything looks like it is working correctly - I can send emails authenticated correctly, but when I send emails to that user (the user is local, but in my mailsql database, I have it setup to be virtual) it puts it in that user's home directory/.maildir.  I want all mail regardless if it is local to be put in /home/vmail/domain/user/.maildir so I can then read that email with squirrelmail or an IMAP client.

Is this possible - how do I completely remove local users and setup only virtual ones?  Is this supposed to happen by default with the mailsql configuration?

So what I did now is change:

```

local_transport = local

```

to

```

local_transport = virtual

```

However, now it cannot open the maildir because it is a directory not a file.

Thanks,

Walter

----------

## rsmereka

I too have been battling with the guide for a couple of months now. I have had to come here to ask questions at times and I must say that even though the guide is very confusing, the community here is great and we end up learning alot. The last issue I had using the old guide was that no remote users were being authenticated. I took the advice of this post and modifed the config for the alternate guide at:

http://www.etherpunk.com/node/232

Here is what I am getting now:

```
May  5 15:54:56 nereid authdaemond: modules="authmysql authpam", daemons=5

May  5 15:54:56 nereid authdaemond: Installing libauthmysql

May  5 15:54:56 nereid authdaemond: libauthmysql.so: cannot open shared object file: No such file or directory

May  5 15:54:56 nereid authdaemond: Installing libauthpam

May  5 15:54:56 nereid authdaemond: Installation complete: authpam

May  5 15:55:00 nereid postfix/postfix-script: starting the Postfix mail system

May  5 15:55:00 nereid postfix/master[1709]: daemon started -- version 2.1.5

May  5 15:55:00 nereid saslauthd[1762]: detach_tty      : master pid is: 1762

May  5 15:55:00 nereid saslauthd[1762]: ipc_init        : listening on socket: /var/lib/sasl2/mux
```

Authdaemond can't find the mysql libauth module. Where do I get this from? The alternate guide seems to be generic since it does not discuss installation or any Gentoo specific stuff like the USE variable. My current USE is:

```
USE="sasl ssl perl mysql pam-mysql imap libwww apache2 maildir pam xml xml2 vda"
```

Any ideas on how I can correct this?

cheers,

Rick

----------

## rsmereka

[solved] I found the problem. I needed to re-

```
emerge courier-authlib
```

since the new guide changes (or is it corrects) the way that authentication takes place.

Rick

----------

## o5gmmob8

Hi,

Normally when you get those errors, it means that you have compiled in support for mysql authentication, but the library has since been removed.  If you didn't have mysql during compilation, it would have removed support, and you wouldn't get that error message about the library being missing.

I would recommend that you look for both mysql and pam_mysql (via emerge -s), also make sure the latest version is installed.

I see you fixed the problem, I knew it was one of those packages.

Walter

----------

## o5gmmob8

Hi,

I figured out my problem, so postfix has several options apparently.  When doing virtual users, if the maildir in the mailsql database (or text file) has an ending slash: /home/vmail/domain/user/.maildir/, then the format of the mailbox is UNIX maildir.  In my mailsql database, I did not have the trailing slash and it wanted to use the path as the location of the textfile for mbox format.

Walter

----------

## Nazadus

I'm the orginal creator of etherpunnk and the person updating that page.

Here is the wiki page:

http://gentoo-wiki.com/HOWTO_Linux_Virtual_Hosting_Server

I bring this up becuase I'm updating my website and the node number won't be the same...

----------

## rprescott

Hi There,

I followed this guide exactly http://www.gentoo.org/doc/en/virt-mail-howto.xml but, I have one problem virtual users are not getting their mail delieved to their mailbox while non-virtual users are?

This something with courier-imap and Im not sure what.  But its driving me nutts any help would be great!

Thanks,

Rob

----------

## Nazadus

Could be any number of things.

Firstly, try running 'postconf -n' to get a list of all your variables.

Check for spelling.

If you believe the vars to be right (which, if you've never set this up before you don't really know... you just have to guess/hope) then the enxt thing to do is to add verbosity to your logs.

Open up /etc/postfix/master.cf

Lines are in a format like this:

```

smtp      inet  n       -       n       -       -       smtpd

```

Add a -v (or -vv for extra verbosity) to the right variable to make:

```

smtp      inet  n       -       n       -       -       smtpd -vv

```

This will add extra verbosity to your /var/log/messages log file.

You can add the '-vv' to many of those, but the main ones are:

smtpd, smtp (all of them), local, and virtual

This will probably help you determine where the problem is happening (for example, it might fail on the SQL lookups... or it might fail due to permissions, etc)

----------

