Greetings,

I am having problems retrieving mail for users in the second virtual mailbox domain (u...@transco.org.au).

Users from the first virtual mailbox domain (u...@transylvania.org.au) can send and receive e-mails to/from
any domain.

1.  Added the second virtual mailbox domain (transco.org.au) to `domains`:

mysql> select * from domains;
+----+---------------------+
| id | domain              |
+----+---------------------+
|  1 | transylvania.org.au |
|  2 | transco.org.au      |
+----+---------------------+



2.  Added a test user (mo...@transco.org.au) to `users`:

mysql> select * from users
    -> where login='mo...@transco.org.au';
+-----+----------------------+----------+---------------+------+------+----------------------+-----------------------+-----------+--------+
| id | login | name | password | uid | gid | home | maildir | quota | active |
+-----+----------------------+----------+---------------+------+------+----------------------+-----------------------+-----------+--------+
| 112 | mo...@transco.org.au | Moron Me | 1kSM07a4Z/xzs | 5000 | 5000 | /var/spool/vmboxbase | mo...@transco.org.au/ | 10000000S | Y |
+-----+----------------------+----------+---------------+------+------+----------------------+-----------------------+-----------+--------+
1 row in set (0.00 sec)



3. The newly created user can successfully send mail to any domain, and replies hit the user's mailbox:

# ls -ltr /var/spool/vmboxbase/mo...@transco.org.au/new
total 12
-rw------- 1 vmail 5000 797 May 5 08:42 1241476955.V8I6bdb9M678211.vega.transylvania.org.au -rw------- 1 vmail 5000 810 May 5 08:50 1241477434.V8I6bda3M893030.vega.transylvania.org.au -rw------- 1 vmail 5000 812 May 5 08:50 1241477451.V8I6bdaaM477729.vega.transylvania.org.au



4. However, if I try to retrieve the mails for mo...@transco.org.au, nothing is retrieved and the following entry
is created in /var/log/maillog (MUA is Thunderbird 2.0.22):

# tail -f maillog
May 5 09:01:36 vega postfix/anvil[18787]: statistics: max connection rate 3/60s for (submission:118.167.129.197) at May 5 08:56:56 May 5 09:01:36 vega postfix/anvil[18787]: statistics: max connection count 1 for (submission:118.167.129.197) at May 5 08:56:54 May 5 09:01:36 vega postfix/anvil[18787]: statistics: max cache size 1 at May 5 08:56:54 May 5 09:01:50 vega dovecot: auth(default): client in: AUTH 1 PLAIN service=POP3 lip=192.168.1.212 rip=192.168.1.101 resp=
May  5 09:01:50 vega dovecot: auth(default): client out: CONT   1
May 5 09:01:50 vega dovecot: auth(default): client in: CONT 1 AG1vcm9uQHRyYW5zY28ub3JnLmF1AG1vcm9u May 5 09:01:50 vega dovecot: auth(default): bsdauth(mo...@transco.org.au,192.168.1.101): lookup May 5 09:01:50 vega dovecot: auth(default): bsdauth(mo...@transco.org.au,192.168.1.101): unknown user May 5 09:01:51 vega dovecot: auth-worker(default): mysql: Connected to localhost (mail) May 5 09:01:51 vega dovecot: auth-worker(default): sql(mo...@transco.org.au,192.168.1.101): query: SELECT password FROM users WHERE login = 'mo...@transco.org.au' and active = 'Y' May 5 09:01:51 vega dovecot: auth(default): client out: OK 1 user=mo...@transco.org.au May 5 09:01:51 vega dovecot: auth(default): master in: REQUEST 1 23790 1 May 5 09:01:51 vega dovecot: auth(default): passwd(mo...@transco.org.au,192.168.1.101): lookup May 5 09:01:51 vega dovecot: auth(default): passwd(mo...@transco.org.au,192.168.1.101): unknown user May 5 09:01:51 vega dovecot: auth-worker(default): sql(mo...@transco.org.au,192.168.1.101): SELECT home, maildir, uid, gid FROM users WHERE login = 'mo...@transco.org.au' AND active = 'Y' May 5 09:01:51 vega dovecot: auth(default): master out: USER 1 mo...@transco.org.au home=/var/spool/vmboxbase maildir=mo...@transco.org.au/ uid=5000 gid=5000 May 5 09:01:51 vega dovecot: pop3-login: Login: user=<mo...@transco.org.au>, method=PLAIN, rip=192.168.1.101, lip=192.168.1.212 May 5 09:01:51 vega dovecot: POP3(mo...@transco.org.au): Disconnected: Logged out top=0/0, retr=0/0, del=0/0, size=0



----------------------------------------------------
The Postfix and Dovecot configuration files:
----------------------------------------------------
# postconf -n
alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
command_directory = /usr/local/sbin
config_directory = /etc/postfix
daemon_directory = /usr/local/libexec/postfix
debug_peer_level = 2
html_directory = /usr/local/share/doc/postfix/html
inet_interfaces = all
mail_owner = _postfix
mailq_path = /usr/local/sbin/mailq
manpage_directory = /usr/local/man
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = transylvania.org.au
myhostname = vega.transylvania.org.au
mynetworks_style = subnet
myorigin = transylvania.org.au
newaliases_path = /usr/local/sbin/newaliases
proxy_interfaces = 192.168.1.200
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix/readme
relay_domains = $mydestination
sample_directory = /etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = _postdrop
smtpd_banner = $myhostname ESMTP $mail_name
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /var/spool/vmboxbase
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000



# more /etc/postfix/mysql/virtual_mailbox_domains.cf
user = vmail
password = vmail
hosts = 127.0.0.1
dbname = mail
table = domains
query = SELECT domain FROM domains WHERE domain='%s'

mysql> select * from domains;
+----+---------------------+
| id | domain              |
+----+---------------------+
|  1 | transylvania.org.au |
|  2 | transco.org.au      |
+----+---------------------+
2 rows in set (0.04 sec)



# more /etc/postfix/mysql/virtual_alias_maps.cf
user = vmail
password = vmail
hosts = 127.0.0.1
dbname = mail
table = alias_maps
query = SELECT alias FROM alias_maps WHERE account='%s'

mysql> select * from alias_maps;
+----+--------------------------------+-------------------------------------+
| id | alias | account |
+----+--------------------------------+-------------------------------------+
| 1 | postmas...@transylvania.org.au | youkno...@local.transylvania.org.au | | 4 | ab...@transylvania.org.au | youkn...@local.transylvania.org.au |
+----+--------------------------------+-------------------------------------+
2 rows in set (0.00 sec)



# more /etc/postfix/mysql/virtual_mailbox_maps.cf
user = vmail
password = vmail
hosts = 127.0.0.1
dbname = mail
table = users
query = SELECT maildir FROM users WHERE login='%s'

mysql> SELECT maildir FROM users WHERE login='mo...@transco.org.au';
+-----------------------+
| maildir               |
+-----------------------+
| mo...@transco.org.au/ |
+-----------------------+
1 row in set (0.00 sec)



# dovecot --version
1.0.2



# dovecot -n
# 1.0.2: /etc/dovecot.conf
base_dir: /var/dovecot/
protocols: imap imaps pop3 pop3s
ssl_cert_file: /etc/ssl/dovecotcert.pem
disable_plaintext_auth: no
login_dir: /var/dovecot/login
login_executable(default): /usr/local/libexec/dovecot/imap-login
login_executable(imap): /usr/local/libexec/dovecot/imap-login
login_executable(pop3): /usr/local/libexec/dovecot/pop3-login
login_user: _dovecot
first_valid_uid: 5000
last_valid_uid: 5000
mail_location: maildir:/var/spool/vmboxbase/%u
mbox_write_locks: fcntl
mail_executable(default): /usr/local/libexec/dovecot/imap
mail_executable(imap): /usr/local/libexec/dovecot/imap
mail_executable(pop3): /usr/local/libexec/dovecot/pop3
mail_plugin_dir(default): /usr/local/lib/dovecot/imap
mail_plugin_dir(imap): /usr/local/lib/dovecot/imap
mail_plugin_dir(pop3): /usr/local/lib/dovecot/pop3
imap_client_workarounds(default): delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep imap_client_workarounds(imap): delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep
imap_client_workarounds(pop3): outlook-idle
pop3_uidl_format(default):
pop3_uidl_format(imap):
pop3_uidl_format(pop3): %08Xu%08Xv
pop3_client_workarounds(default):
pop3_client_workarounds(imap):
pop3_client_workarounds(pop3): outlook-no-nuls oe-ns-eoh
auth default:
  verbose: yes
  debug: yes
  debug_passwords: yes
  passdb:
    driver: bsdauth
  passdb:
    driver: sql
    args: /etc/dovecot-mysql.conf
  userdb:
    driver: passwd
  userdb:
    driver: sql
    args: /etc/dovecot-mysql.conf



# more /etc/dovecot-mysql.conf
# This file is opened as root, so it should be owned by root and mode 0600.
#
# http://wiki.dovecot.org/AuthDatabase/SQL
#
# For the sql passdb module, you'll need a database with a table that
# contains fields for at least the userid and password. If you want to
# use the u...@domain syntax, you might want to have a separate domain
# field as well.
#
# If your users all have the same uig/gid, and have predictable home
# directories, you can use the static userdb module to generate the home
# dir based on the userid and domain. In this case, you won't need fields
# for home, uid, or gid in the database.
#
# If you prefer to use the sql userdb module, you'll want to add fields
# for home, uid, and gid. Here is an example table:
#
# CREATE TABLE users (
#     userid VARCHAR(128) NOT NULL,
#     password VARCHAR(64) NOT NULL,
#     home VARCHAR(255) NOT NULL,
#     uid INTEGER NOT NULL,
#     gid INTEGER NOT NULL,
#     active CHAR(1) DEFAULT 'Y' NOT NULL
# );

# Database driver: mysql, pgsql, sqlite
#driver =
driver = mysql

# Database connection string. This is driver-specific setting.
#
# pgsql:
#   For available options, see the PostgreSQL documention for the
#   PQconnectdb function of libpq.
#
# mysql:
#   Basic options emulate PostgreSQL option names:
#     host, port, user, password, dbname
#
#   But also adds some new settings:
#     client_flags        - See MySQL manual
#     ssl_ca, ssl_ca_path - Set either one or both to enable SSL
#     ssl_cert, ssl_key   - For sending client-side certificates to server
# ssl_cipher - Set minimum allowed cipher security (default: HIGH)
#
#   You can connect to UNIX sockets by using host: host=/var/run/mysql.sock
#   Note that currently you can't use spaces in parameters.
#
# sqlite:
#   The path to the database file.
#
# Examples:
#   connect = host=192.168.1.1 dbname=users
# connect = host=sql.example.com dbname=virtual user=virtual password=blarg
#   connect = /etc/dovecot/authdb.sqlite
#
#connect = dbname=virtual user=virtual
connect = host=localhost dbname=mail user=dovecot password=dovecot

# Default password scheme.
#
# List of supported schemes is in
# http://wiki.dovecot.org/Authentication/PasswordSchemes
#
#default_pass_scheme = PLAIN-MD5
default_pass_scheme = CRYPT

# Query to retrieve the password.
#
# This query must return only one row with "user" and "password" columns.
# The query can also return other fields which have a special meaning, see
# http://wiki.dovecot.org/PasswordDatabase/ExtraFields
#
# The "user" column is needed to make sure the username gets used with exactly # the same casing as it's in the database. Note that if you store username and
# domain in separate fields, you most likely want to return a combination of
# them as the "user" column, otherwise the domain gets stripped.
#
# Commonly used available substitutions (see
# http://wiki.dovecot.org/Variables for full list):
#   %u = entire userid
#   %n = user part of u...@domain
#   %d = domain part of u...@domain
#
# Note that these can be used only as input to SQL query. If the query outputs
# any of these substitutions, they're not touched. Otherwise it would be
# difficult to have eg. usernames containing '%' characters.
#
# Example:
# password_query = SELECT concat(userid, '@', domain) AS user, password FROM users WHERE userid = '%n' AND domain = '%
d'
# password_query = SELECT pw AS password FROM users WHERE userid = '%u' AND active = 'Y'
#
password_query = SELECT password FROM users WHERE login = '%u' and active = 'Y'

# Query to retrieve the user information.
#
# The query must return only one row. Commonly returned columns are:
#   uid - System UID
#   gid - System GID
#   home - Home directory
#   mail - Mail location
#
# Either home or mail is required. uid and gid are required. If more than one # row is returned or there are missing fields, the login will fail. For a list
# of all fields that can be returned, see
# http://wiki.dovecot.org/UserDatabase/ExtraFields
#
# Examples
# user_query = SELECT home, uid, gid FROM users WHERE userid = '%n' AND domain = '%d' # user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u' # user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
#
#user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
user_query = SELECT home, maildir, uid, gid FROM users WHERE login = '%u' AND active = 'Y'

# If you wish to avoid two SQL lookups (passdb + userdb), you can use
# userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll
# also have to return userdb fields in password_query prefixed with "userdb_"
# string. For example:
#password_query = SELECT userid as user, password, home as userdb_home, uid as userdb_uid, gid as userdb_gid FROM users WHERE userid = '%u'



----------------------------------------------------------------------------------------------------
password_query = SELECT password FROM users WHERE login = '%u' and active = 'Y'
----------------------------------------------------------------------------------------------------
mysql> SELECT password FROM users WHERE login = 'mo...@transco.org.au' and active = 'Y';
+---------------+
| password      |
+---------------+
| 1kSM07a4Z/xzs |
+---------------+
1 row in set (0.00 sec)



---------------------------------------------------------------------------------------------------
user_query = SELECT home, maildir, uid, gid FROM users WHERE login = '%u' AND active = 'Y'
---------------------------------------------------------------------------------------------------
mysql> SELECT home, maildir, uid, gid FROM users WHERE login = 'mo...@transco.org.au' AND active = 'Y';
+----------------------+-----------------------+------+------+
| home                 | maildir               | uid  | gid  |
+----------------------+-----------------------+------+------+
| /var/spool/vmboxbase | mo...@transco.org.au/ | 5000 | 5000 |
+----------------------+-----------------------+------+------+
1 row in set (0.00 sec)



Any suggestion? What's wrong with my test configuration, why user mo...@transco.org.au can't retrieve the mail?

Regards,

tepertyu

Reply via email to