Hello

Im having issues login to dovecot using imap through telnet.

Im running Linux 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u1 (2019-09-20) x86_64 GNU/Linux

Im totally new to setting up mailservers. I havesetup a postfix for SMTP and it can receive emails. Postfix version is mail_version = 3.1.12

I have also installed Dovecot version:2.2.27 (c0f36b0) My configuration is such that POSTFIX is configured to use DOVECOT SASL through local socket.

My system is configured to store emails in /var/mail/owndomain.org/<username>. For each domain i have my own passwd file where dovecot is supposed to lookup usernames and passwords. /var/mail/owndomain.org/passwd.

I have created virtualuser for accessing mails and authenticating users. My dovecot (dovecot -n output) configuration is:

-------------------------------------------------------------

# 2.2.27 (c0f36b0): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.16 (fed8554)
# OS: Linux 4.9.0-11-amd64 x86_64 Debian 9.11
auth_debug = yes
auth_mechanisms = plain login
auth_verbose = yes
debug_log_path = /var/log/dovecot-debug.log
disable_plaintext_auth = no
info_log_path = /var/log/dovecot-info.log
listen = 192.168.2.2
log_path = /var/log/dovecot.log
mail_home = /var/mail/home/%d/%n
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%d/%n
mail_privileged_group = virtualmail
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  driver = pam
}
passdb {
  args = username_format=%n /var/mail/%d/passwd
  driver = passwd-file
}
pop3_uidl_format = %g
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  user = dovecot
}
ssl = no
userdb {
  driver = passwd
}
userdb {
  args = username_format=%n /var/mail/%d/passwd
  default_fields = uid=virtualmail gid=virtualmail home=/var/mail/%d/%n
  driver = passwd-file
}
verbose_proctitle = yes
----------------------------------------

Now the problem: I was testing the configuration using telnet. POSTFIX receives email, stores it. No problem. When i tried to log in onto Dovecot IMAP using Telnet i get this message:

* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH-LOGIN] Dovecot ready.
a login "username@owndomain.org" "test"
a NO [UNAVAILABLE] Internal error occured. Refer to server log for more information.

I have enabled verbose logging and this is the output of logs: /var/log/dovecot.log had this message:

Nov 16 14:20:49 auth: Error: plain(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): user not found from any userdbs
Nov 16 14:20:49 imap: Error: Authenticated user not found from userdb, auth lookup id=684589057 (client-pid=9601 client-id=1)

/var/log/dovecot-debug.log had this message:

Nov 16 14:20:18 auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
Nov 16 14:20:18 auth: Debug: Read auth token secret from /var/run/dovecot/auth-token-secret.dat
Nov 16 14:20:18 auth: Debug: auth client connected (pid=9601)
Nov 16 14:20:47 auth: Debug: client in: AUTH    1       PLAIN   service=imap    session=RF4llXaXisPAqAmD        lip=192.168.2.2 rip=192.168.9.131       lport=143       rport=$
Nov 16 14:20:47 auth-worker(9603): Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
Nov 16 14:20:47 auth-worker(9603): Debug: pam(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): lookup service=dovecot
Nov 16 14:20:47 auth-worker(9603): Debug: pam(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): #1/1 style=1 msg=Password:
Nov 16 14:20:49 auth: Debug: passwd-file /var/mail/owndomain.org/passwd: Read 2 users in 0 secs
Nov 16 14:20:49 auth: Debug: passwd-file(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): lookup: user=username file=/var/mail/owndomain.org/passwd
Nov 16 14:20:49 auth: Debug: client passdb out: OK      1       user=username@owndomain.org
Nov 16 14:20:49 auth: Debug: master in: REQUEST 684589057       9601    1       a61dd67ee43390596ddf86e6c08db6f9        session_pid=9604        request_auth_token
Nov 16 14:20:49 auth-worker(9603): Debug: passwd(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): lookup
Nov 16 14:20:49 auth: Debug: passwd-file(username@owndomain.org,192.168.9.131,<RF4llXaXisPAqAmD>): lookup: user=username file=/var/mail/owndomain.org/passwd
Nov 16 14:20:49 auth: Debug: master userdb out: NOTFOUND        684589057

And i am completelly clueless what is the problem. Because it seems as if the password was found but the user is not? Password and user are looked up in the same passwd file. Have i forgotten something to setup? Any help or guidance is appreciated!

I have also posted the issue on: https://serverfault.com/questions/992108/dovecot-cant-login-virtual-user

Thanks
A.