# Virtual Mailhosting System W Postfix Guide problem (solved)

## GoofyHMG

I am following this guide 

( Virtual Mailhosting System with Postfix Guide)

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

I set up the users in mysql table and when I go log in through squirrelmail I get 

ERROR:

Unknown error: [ALERT] Fatal error: .maildir: Permission denied 

The permissions are set to 700 on the file. The owner of the maildir is the user the email was sent to. The directory was created automatically when I sent the first email to the user. The mail is getting to the maildir because I can see it when I go to the maildir.  

Changing the permissions on the file to 777 

It logs me in but I get 

ERROR: Connection dropped by IMAP server.

Query: SUBSCRIBE "INBOX.Sent"

(on the left bar) 

and 

ERROR: Could not complete request.

Query: SELECT "INBOX"

Reason Given: Unable to open this mailbox. 

(on the top.)

I am using sendmail and have gamin installed. 

From My Logs:

May  9 22:35:55 www imapd-ssl: chdir .maildir: Permission denied

I was also succesful in sending mail with mailx.Last edited by GoofyHMG on Thu May 11, 2006 9:37 pm; edited 1 time in total

----------

## mocsokmike

Maybe you need to give permissions to the apache user as well, because I think squirrelmail wants to create its system folders (Sent and Trash), but cannot do that as it has no permission to do this as a web-app.

----------

## langthang

 *mocsokmike wrote:*   

> Maybe you need to give permissions to the apache user as well, because I think squirrelmail wants to create its system folders (Sent and Trash), but cannot do that as it has no permission to do this as a web-app.

 

wrong advise. squirrelmail use IMAP connection to display the mailbox.

----------

## celsum

I've used the same documentation to setup my mail server, but I have a problem, and can't find the problem for it.

I have both regitered and virtual users on the same domain. When I create a new registered user, add it to the database, the maildir for this users gets created automatically when I send an email to this user for the first time. However, if I create a virtual user, i.e. oly adding him to the database, the maildir doesn't get created automatically.

Here are two sample rows from my users table:

1 | test@domain.com	|	test	|	Test Mailbox	|	1234	|	567	|	/home/test	|	/home/test/.maildir	|		|	y

2 | vasya@domain.com | vasya | Vasya | 2222 | 333 | /home/vmail | /home/vmail/vdomain/vasya/.maildir/ |  | y

The first row represents a user that is registered in the system, and 1234 and 567 are his respective uid and gid. His maildir - /home/test/.maildir - got created automatically.

The second row represents a virtual user 'vasya' that is not in the system, and 2222 and 333 are the respective uid and gid of the 'vmail' user that is in the system. 

So, the maildir - /home/vmail/vdomain/vasya/.maildir/ - doesn't get created when I send an email to vasya@domain.com

Any help please?

P.S.: Also I noticed that if in the first row I change the maildir from '/home/test/.maildir' to '/home/test/mail/.maildir', this folder doesn't get created automatically.

----------

## mocsokmike

GoofyHMG:

 *Quote:*   

> The permissions are set to 700 on the file. The owner of the maildir is the user the email was sent to.

 

If the user is a virtual user (not a local user) in your database, you need to chown the whole .maildir to vmail:vmail to make it work properly (section 9 in the howto).

celsum:

I usually create the .maildir folders with the maildirmake command, because of the same error you mentioned.

Try:

```
maildirmake /path/to/there/.maildir
```

And chown the whole .maildir folder to vmail:vmail.

----------

## GoofyHMG

My users are regular users though, not virtual acounts. Does that matter? I am not in front of the machine right now but could the problem be that the uid and the gid is not the same in the db as it is on the user level. Not sure if I worded that correctly. How can I get my user id say if I had a user called bob fromthe system to make sure it matches the user on the DB.

----------

## celsum

GoofyHMG:

The maildirmake command works perfectly. However, it doesn't resolve my problem.

It gets very interesting though. 

What I had before:

Virtual user vasya with maildir in database as /home/vmail/domain/vasya/.maildir but no actual folder in the system (supposed to be created automatically, but it didn't). The homedir, uid, and gid in the database are those of of the user vmail in the system. 

When sending email to vasya@domain.com I get a reply saying no such user exists. When checking email with Outlook, it says that Outlook couldn't login into the POP3 account.

Real user test with maildir in database as /home/test/.maildir but no actual folder in the system, and it does get created automatically. The homedir, uid, and gid in the database are those of of the user test in the system.

I used maildirmake to create new maildirs for both users, and this is what I have now:

Virtual user vasya with maildir in database as /home/vmail/domain/vasya/.maildir and an actual maildir folder in the system. The homedir, uid, and gid in the database are those of the user vmail in the system. 

When sending email to vasya@domain.com I get a reply saying no such user exists. However, when checking email with Outlook, Outlook can login into the POP3 account, but there is no mail for this user.

Real user test with maildir in database as /home/test/mail/.maildir (note that it's different than before) and an actual maildir folder in the system. The homedir, uid, and gid in the database are those of the user test in the system. 

When I send email to test@domain.com I DON'T get a reply saying there is no such user, but when I check email for user test, there appears to be no new mail for him. I found that the email gets received into the system, but it gets stored in a /home/test/.maildir which is not the same as in the database, and apparently outlook is trying to get the new email from the folder indicated in the database.

All folders are chown-ed recursively and correctly.

Now I'm really confused, any help would be appreciated.

Thnx in advance.

----------

## langthang

check those MYSQL_* paramters in /etc/courier/authlib/authmysqlrc (Code Listing 10.1) , especially

```
MYSQL_UID_FIELD         uid

MYSQL_GID_FIELD         gid

MYSQL_LOGIN_FIELD       email

MYSQL_HOME_FIELD        homedir
```

make sure corresponding values in mysql tables are correct.

----------

## GoofyHMG

My hunch was correct.

my uid and gid was wrong!

make sure that the uid and gid values are correct.

----------

## celsum

GoofyHMG: 

Somehow I also had the gid wrong.

langthang:

I went through the whole guide guide, and everything appears to be correct.

But I still have this problem.

----------

## GoofyHMG

check the values for the maildir in the mysql table it may be pointing to the wrong folder

----------

## celsum

No, everything is correct in the db:

(user - homedir - maildir) copied directly from db

vasya@domain.com - /home/vmail - /home/vmail/domain/vasya/.maildir/

greg@domain.com	- /home/test - /home/test/mail/.maildir/

Here are my logs.

This one is when outlook is checking for mail:

```
May 13 20:07:23 celsum pop3d: Connection, ip=[::ffff:xx.xxx.xxx.xx]

May 13 20:07:23 celsum pop3d: chdir /home/vmail/domain/vasya/.maildir/: No such file or directory

```

```

May 12 18:12:41 celsum pop3d: Connection, ip=[::ffff:xx.xxx.xxx.xx]

May 12 18:12:41 celsum pop3d: chdir /home/test/mail/.maildir/: No such file or directory

```

So when I'm checking email, postfix is looking into the correct folder but doesn't find it.

This one is when I send an email to a user:

```

May 12 18:13:24 celsum postfix/smtpd[16630]: starting TLS engine

May 12 18:13:24 celsum postfix/smtpd[16630]: warning: smtpd_peer_init: xx.xxx.xxx.xx: hostname hostxxxxxxxx.com verification failed: Name or service not known

May 12 18:13:24 celsum postfix/smtpd[16630]: connect from unknown[xx.xxx.xxx.xx]

May 12 18:13:24 celsum postfix/smtpd[16630]: 7693C8DC17: client=unknown[xx.xxx.xxx.xx], sasl_method=LOGIN, sasl_username=yevgen@domain.com

May 12 18:13:24 celsum postfix/cleanup[16638]: 7693C8DC17: message-id=<20060512221324.7693C8DC17@mail.domain.com>

May 12 18:13:24 celsum postfix/qmgr[14141]: 7693C8DC17: from=<yevgen@domain.com>, size=2139, nrcpt=1 (queue active)

May 12 18:13:24 celsum postfix/local[16640]: 7693C8DC17: to=<test@domain.com>, relay=local, delay=0, status=sent (delivered to maildir)

May 12 18:13:24 celsum postfix/qmgr[14141]: 7693C8DC17: removed

May 12 18:13:27 celsum postfix/smtpd[16630]: disconnect from unknown[xx.xxx.xxx.xx]

```

```

May 13 20:02:48 celsum postfix/smtpd[26404]: starting TLS engine

May 13 20:02:48 celsum postfix/smtpd[26404]: warning: smtpd_peer_init: xx.xxx.xxx.xx: hostname hostxxxxxxxx.com verification failed: Name or service not known

May 13 20:02:48 celsum postfix/smtpd[26404]: connect from unknown[xx.xxx.xxx.xx]

May 13 20:02:48 celsum postfix/smtpd[26404]: 6330D3723A: client=unknown[xx.xxx.xxx.xx], sasl_method=LOGIN, sasl_username=yevgen@domain.com

May 13 20:02:48 celsum postfix/cleanup[26412]: 6330D3723A: message-id=<20060514000248.6330D3723A@mail.domain.com>

May 13 20:02:48 celsum postfix/qmgr[14141]: 6330D3723A: from=<yevgen@domain.com>, size=2132, nrcpt=1 (queue active)

May 13 20:02:48 celsum postfix/local[26414]: 6330D3723A: to=<vasya@domain.com>, relay=local, delay=0, status=bounced (unknown user: "vasya")

May 13 20:02:48 celsum postfix/qmgr[14141]: 6330D3723A: removed

```

Email sent to test@domain.com is delivered into /home/test/.maildir/ which is not the same as in db.

Also I tried creating both maildirs using the maildirmake command, but it still doesn't help.

Still confused about all this ....   :Confused:   :Confused:   :Confused: 

----------

## langthang

IMO, a doamin either a local or virtual domain. It is very confusing when you try to set it for both ( ie test is a local user and vasya is a virtual user of the same domain )

you can try solution below for your problem

1. Problem login with 'test' user:

change maildir value for 'test' in mysql to /home/test/.maildir/

2. Mail for 'vasya' user bounced

add a parameter to main.cf

```
virtual_mailbox_domains = your.virtual.domain1 your.virtual.domain2
```

----------

