0

everybody. I've been looking for the mistake in a few days now..

When i want to connect my Webmail with my E-Mail Server via Imap/Smtp, i got this error: "Authentification failed". When you need more Informations, please ask. Can you guys find my config issue?

Kind regards.

Error message:

Nov 19 19:00:43 mail dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=145.eineip, lip=188nocheineip, session=<mSW4Swh71NCR/idK>
Nov 19 19:01:03 mail dovecot: imap-login: Disconnected (auth failed, 3 attempts in 14 secs): user=<test>, method=PLAIN, rip=145.eineip, lip=188.eineip, session=<omsPTAh71tCR/idK>
Nov 19 19:01:29 mail dovecot: imap-login: Disconnected (auth failed, 3 attempts in 26 secs): user=<test@domain.eu>, method=PLAIN, rip=145.weitereip, lip=188.nochip, session=<wq7fTAh719CR/idK>

Dovecot config:

###Dovecot service
##################
service imap-login {
 inet_listener imap {
 port = 143
}
inet_listener imaps {
 port = 993
 ssl = yes
 }
}

# Change this to where your mail root is, this needs to match whatever structure postfix expects....
# See also: https://wiki.dovecot.org/MailLocation - %d domain, %u full username, %n user part (%u with no domain)
mail_location = maildir:/var/mail/vmail/%u/

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 = 
}

protocols = "imap pop3"
# change to 'no' if you don't have ssl cert/keys, and comment out ssl_cert/ssl_key
ssl = no
#ssl_cert = </etc/letsencrypt/live/mail.domain.eu/cert.pem
#ssl_key = </etc/letsencrypt/live/mail.domain.eu/privkey.pem

# login is for outlook express smtpd auth
auth_mechanisms = plain login

# If you're having trouble, try uncommenting these :
#auth_debug = yes
#auth_debug_passwords = yes

userdb { 
driver = sql
args = /etc/dovecot/dovecot-sql.conf 
}

passdb { 
driver = sql
args = /etc/dovecot/dovecot-sql.conf 
}

# Uncomment this if you want Postfix to be able to do smtpd auth through dovecot
# At a minimum Postfix probably needs : smtpd_sasl_type = dovecot 
# And additionally: smtpd_sasl_path = private/auth
service auth {
unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    user = postfix
    group = postfix
}
}

# Needs to match Postfix virtual_uid_maps
first_valid_uid = 1001 

# allow plaintext auth (change to 'yes' to block plaintext passwords)
disable_plaintext_auth = no

Postfix config:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $domain ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mail.domain.eu, localhost.domain.eu, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

#######
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_alias_maps =
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_maps =
proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
# if you let postfix store your mails directly (without using maildrop, dovecot deliver etc.)
#virtual_mailbox_base = /var/mail/vmail
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
#virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix /sql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes

Dovecot SQL

connect = host=localhost dbname=name user=name password=psw
# Use either 
driver = mysql
# Or 
# driver = pgsql

# Default password scheme - change to match your Postfixadmin setting.
# depends on your $CONF['encrypt'] setting:
# md5crypt  -> MD5-CRYPT
# md5       -> PLAIN-MD5
# cleartext -> PLAIN
default_pass_scheme = MD5-CRYPT

# Query to retrieve password. user can be used to retrieve username in other
# formats also.

password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1'

# Query to retrieve user information, note uid matches dovecot.conf AND         Postfix virtual_uid_maps parameter.
user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE username = '%u' AND active='1'


# MYSQL :
user_query = SELECT CONCAT('/var/mail/vmail/', maildir) AS home, 1001 AS uid, 1001 AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE         username = '%u' AND active='1'
# PostgreSQL : (no Quota though) :
# user_query = SELECT '/var/vmail/mail/' || maildir AS home, 1001 as uid, 1001 as gid FROM mailbox WHERE username = '%u' AND active = '1'
0

A few things - your ability to log in to webmail has nothing to do with Postfix or SMTP (that may be relevant for actually sending emails, nothing else)

You appear to assume webmail uses IMAP authentication (which is a reasonable but not guaranteed assumption) You should get IMAP working and check it with a regular mail client like thunderbird or outlook. (Or use telnet and IMAP commands, but that's quite advanced) to check IMAP works.

Your current dovecot configuration appears to only use an SQL database to authenticate users You either need to change this behaviour or add the admin to the SQL database. (You can see this behaviour because the driver to check user and password in the config is SQL). You have not provided the SQL config file/etc/dovecot/dovecot-sql.conf but that file should tell you what database and fields need to be used.

Alternatively change the driver to use the system database as per https://wiki.dovecot.org/PasswordDatabase/PAM - note that this could decrease your systems security. You will also need to change your config to allow plaintext author to make this work.

8
  • Hel lo. Thank you for your answer. in my question, you can see my sql conf. i have already an db user.:/ is it possible, that dovecot wont look to the database? – Cyberpunk7711 Nov 20 '18 at 19:00
  • At the top of your Dovecot SQL file there is a line "connect = host=localhost dbname=name user=name password=psw" - if this line does not match connection details required by the database, Dovecot will not authenticate. Similarly if the details of the user in the database dont match, it will fail. I also observe that (a) You have 2 user_query statements, you should comment out the incorrect one and (b) Your query statement requires that the "active=1", so make sure that this is true for the user in the database... – davidgo Nov 20 '18 at 19:32
  • In order to further debug this, I would turn on query logging in MySQL and see what that is getting. Looking at the MySQL logs should reveal if there are connection errors, and looking at the query logging (and reproducing the queries) should give you a good idea as to where the failure is happening and why. – davidgo Nov 20 '18 at 19:33
  • Another thing to look at is the way the password is encrypted in the database. You have a default_pass_scheme of MD5-CRYPT. According to wiki.dovecot.org/Authentication/PasswordSchemes the encrypted password needs to start $1$ - if this is not the case, I expect it won't work. You may have more flexibility if you change MD5-CRYPT to CRYPT. – davidgo Nov 20 '18 at 19:40
  • sorry that i waste your time. the line is normally filled with my passwort etc. but i dont want to share that with other:D I have tried both types of user_query but i get every time the same error. is it possible, that the user_query or user_password is wrong? I cand find a good solution via web. I also have "active=1" at the end. I have also changed MD5-CRYPT to CRYPT. When i use $1$CRYPT i got an error. I also have activated my sql debug. but i got only these errors: – Cyberpunk7711 Nov 20 '18 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.