1 (edited by petero 2021-08-05 20:39:56)

Topic: Lost connection to mail dir -Dovecot Authentication failure

Hi,
After a reboot, SoGo client lost mail connection "No mailbox selected ". I reinstalled dovecot and ran sudo bash iRedMail.sh
Yes To < Question > Use it for mail server setting? [y|N]
These were skipped
< SKIP > Function: add_user_vmail.
< SKIP > Function: add_user_mlmmj.
< SKIP > Function: add_user_iredadmin.
< SKIP > Function: add_user_iredapd.
< SKIP > Function: add_user_netdata.
< SKIP > Function: mysql_setup.
< SKIP > Function: postfix_setup.
< SKIP > Function: dovecot_setup.
< SKIP > Function: web_server_config.
< SKIP > Function: mlmmj_config.
< SKIP > Function: mlmmjadmin_config.
Note calendar and address book works and stores.
How do I reconfig dovecot correctly?

Aug  5 06:47:58 server dovecot: imap-login: Disconnected (auth failed, 1 attempts in 0 secs): user=<kingsley@server.thekingsley.co.uk>, rip=81.xxx.xx.172, lip=192.168.1.252, session=<wiWoTMrICfVRlk2s>
A

See below dovecot.conf file which isn't as it should be


==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.4.0
- Deployed with iRedMail Easy or the downloadable installer? downloadable
- Linux/BSD distribution name and version: Ubuntu 20.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): mariadb
- Web server (Apache or Nginx):nginx
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
## Dovecot configuration file

# If you're in a hurry, see http://wiki2.dovecot.org/QuickConfiguration

# "doveconf -n" command gives a clean output of the changed settings. Use it
# instead of copy&pasting files when posting to the Dovecot mailing list.

# '#' character and everything after it is treated as comments. Extra spaces
# and tabs are ignored. If you want to use either of these explicitly, put the
# value inside quotes, eg.: key = "# char and trailing whitespace  "

# Most (but not all) settings can be overridden by different protocols and/or
# source/destination IPs by placing the settings inside sections, for example:
# protocol imap { }, local 127.0.0.1 { }, remote 10.0.0.0/8 { }

# Default values are shown for each setting, it's not required to uncomment
# those. These are exceptions to this though: No sections (e.g. namespace {})
# or plugin settings are added by default, they're listed only as examples.
# Paths are also just examples with the real defaults being based on configure
# options. The paths listed here are for configure --prefix=/usr
# --sysconfdir=/etc --localstatedir=/var

# Enable installed protocols
!include_try /usr/share/dovecot/protocols.d/*.protocol

# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
#listen = *, ::

# Base directory where to store runtime data.
#base_dir = /var/run/dovecot/

# Name of this instance. In multi-instance setup doveadm and other commands
# can use -i <instance_name> to select which instance is used (an alternative
# to -c <config_path>). The instance name is also added to Dovecot processes
# in ps output.
#instance_name = dovecot

# Greeting message for clients.
#login_greeting = Dovecot ready.

# Space separated list of trusted network ranges. Connections from these
# IPs are allowed to override their IP addresses and ports (for logging and
# for authentication checks). disable_plaintext_auth is also ignored for
# these networks. Typically you'd specify your IMAP proxy servers here.
#login_trusted_networks =

# Space separated list of login access check sockets (e.g. tcpwrap)
#login_access_sockets =

# With proxy_maybe=yes if proxy destination matches any of these IPs, don't do
# proxying. This isn't necessary normally, but may be useful if the destination
# IP is e.g. a load balancer's IP.
#auth_proxy_self =

# Show more verbose process titles (in ps). Currently shows user name and
# IP address. Useful for seeing who are actually using the IMAP processes
# (eg. shared mailboxes or if same uid is used for multiple accounts).
#verbose_proctitle = no

# Should all processes be killed when Dovecot master process shuts down.
# Setting this to "no" means that Dovecot can be upgraded without
# forcing existing client connections to close (although that could also be
# a problem if the upgrade is e.g. because of a security fix).
#shutdown_clients = yes

# If non-zero, run mail commands via this many connections to doveadm server,
# instead of running them directly in the same process.
#doveadm_worker_count = 0
# UNIX socket or host:port used for connecting to doveadm server
#doveadm_socket_path = doveadm-server

# Space separated list of environment variables that are preserved on Dovecot
# startup and passed down to all of its child processes. You can also give
# key=value pairs to always set specific settings.
#import_environment = TZ

##
## Dictionary server settings
##

# Dictionary can be used to store key=value lists. This is used by several
# plugins. The dictionary can be accessed either directly or though a
# dictionary server. The following dict block maps dictionary names to URIs
# when the server is used. These can then be referenced using URIs in format
# "proxy::<name>".

dict {
  #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
  #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
}

# Most of the actual configuration gets included below. The filenames are
# first sorted by their ASCII value and parsed in that order. The 00-prefixes
# in filenames are intended to make it easier to understand the ordering.
!include conf.d/*.conf

# A config file can also tried to be included without giving an error if
# it's not found:
!include_try local.conf
!include_try /etc/dovecot/conf-enabled/*.conf
!include_try /opt/iredmail/custom/dovecot/conf-enabled/*.conf

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Lost connection to mail dir -Dovecot Authentication failure

Seems your Dovecot config file is messy. What's the full content of /etc/dovecot/dovecot.conf?

3

Re: Lost connection to mail dir -Dovecot Authentication failure

ZhangHuangbin wrote:

Seems your Dovecot config file is messy. What's the full content of /etc/dovecot/dovecot.conf?

Thank you Zhang,
Attached is conf file - it is not the one that iRedmail configured - I re-installed dovecot in an attempt to re-connect with the maildir. The original failed when I was adding the letsencrypt lines, maybe a typo at that point.
Peter
------------------------------------------
    # More details about Dovecot settings:
    #   - http://wiki2.dovecot.org/
    #   - http://wiki2.dovecot.org/Variables

    # Listen addresses.
    #   - '*' means all available IPv4 addresses.
    #   - '[::]' means all available IPv6 addresses.
    # Listen on all available addresses by default
    listen = * [::]

    #base_dir = /var/run/dovecot
    mail_plugins = quota mailbox_alias acl mail_log notify stats

    # Enabled mail protocols.
    protocols = pop3 imap sieve lmtp

    # User/group who owns the message files:
    mail_uid = 2000
    mail_gid = 2000

    # Assign uid to virtual users.
    first_valid_uid = 2000
    last_valid_uid = 2000

    # Logging. Reference: http://wiki2.dovecot.org/Logging
    #
    # Use syslog
    syslog_facility = local5
    # Log file path if we use internal log system
    #log_path = /var/log/dovecot/dovecot.log

    # Debug
    mail_debug = yes
    auth_verbose = yes
    auth_debug = yes
    auth_debug_passwords = yes
    # Possible values: no, plain, sha1.
    #auth_verbose_passwords = no

    # SSL: Global settings.
    # Refer to wiki site for per protocol, ip, server name SSL settings:
    # http://wiki2.dovecot.org/SSL/DovecotConfiguration
    ssl_protocols =  !SSLv2 !SSLv3
    ssl = required
    verbose_ssl = no
    # ssl_ca = </etc/SectigoSSL/21062021/chain.pem
   # ssl_cert = </etc/SectigoSSL/21062021/fullchain.pem
    #ssl_key = </etc/SectigoSSL/21062021/privkey.pem

    # Fix 'The Logjam Attack'
    ssl_cipher_list = ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5
    ssl_prefer_server_ciphers = yes

    # With disable_plaintext_auth=yes AND ssl=required, STARTTLS is mandatory.
    # Set disable_plaintext_auth=no AND ssl=yes to allow plain password transmitted
    # insecurely.
    disable_plaintext_auth = yes

    # Allow plain text password per IP address/net
    #remote 192.168.0.0/24 {
    #   disable_plaintext_auth = no
    #}

    # Mail location and mailbox format.
    mail_location = maildir:%Lh/Maildir/:INDEX=%Lh/Maildir/

    # Authentication related settings.
    # Append this domain name if client gives empty realm.
    #auth_default_realm = domain.com (example)

    # Authentication mechanisms.
    auth_mechanisms = PLAIN LOGIN

    # Limits the number of users that can be logging in at the same time.
    # Default is 100. This can be overridden by `process_limit =` in
    # `service [protocol]` block.
    # e.g.
    #       protocol imap-login {
    #           ...
    #           process_limit = 500
    #       }
    #default_process_limit = 100

    # Mail delivery log format
    deliver_log_format = from=%{from}, envelope_sender=%{from_envelope}, subject=%{subject}, msgid=%m, size=%{size}, %$

    service auth {
        unix_listener /var/spool/postfix/private/dovecot-auth {
            user = postfix
            group = postfix
            mode = 0666
        }
        unix_listener auth-master {
            user = vmail
            group = vmail
            mode = 0666
        }
        unix_listener auth-userdb {
            user = vmail
            group = vmail
            mode = 0660
        }
    }

    # LMTP server (Local Mail Transfer Protocol).
    # Reference: http://wiki2.dovecot.org/LMTP
    service lmtp {
        user = vmail

        # For higher volume sites, it may be desirable to increase the number of
        # active listener processes. A range of 5 to 20 is probably good for most
        # sites.
        process_min_avail = 5

        # Logging.
        # Require 'log_path =' in 'protocol lmtp {}' block.
        executable = lmtp -L

        # Listening on socket file and TCP
        unix_listener /var/spool/postfix/private/dovecot-lmtp {
            user = postfix
            group = postfix
            mode = 0600
        }

        inet_listener lmtp {
            # Listen on localhost (ipv4)
            address = 127.0.0.1
            port = 24
        }
    }

    # Virtual mail accounts.
    userdb {
        args = /etc/dovecot/dovecot-mysql.conf
        driver = sql
    }
    passdb {
        args = /etc/dovecot/dovecot-mysql.conf
        driver = sql
    }

    # Master user.
    # Master users are able to log in as other users. It's also possible to
    # directly log in as any user using a master password, although this isn't
    # recommended.
    # Reference: http://wiki2.dovecot.org/Authentication/MasterUsers
    auth_master_user_separator = *
    passdb {
        driver = passwd-file
        args = /etc/dovecot/dovecot-master-users
        master = yes
    }

    plugin {
        # Quota configuration.
        # Reference: http://wiki2.dovecot.org/Quota/Configuration
        quota = dict:user::proxy::quotadict

        # Set default quota rule if no quota returned from SQL/LDAP query.
        #quota_rule = *:storage=1G
        #quota_rule2 = *:messages=0
        #quota_rule3 = Trash:storage=1G
        #quota_rule4 = Junk:ignore

        # Quota warning.
        #
        # If user suddenly receives a huge mail and the quota jumps from
        # 85% to 95%, only the 95% script is executed.
        #
        # Only the command for the first exceeded limit is executed, so configure
        # the highest limit first.
        quota_warning = storage=100%% quota-warning 100 %u
        quota_warning2 = storage=95%% quota-warning 95 %u
        quota_warning3 = storage=90%% quota-warning 90 %u
        quota_warning4 = storage=85%% quota-warning 85 %u

        # allow user to become max 10% (or 50 MB) over quota
        quota_grace = 10%%
        #quota_grace = 50 M

        # Custom Quota Exceeded Message.
        # You can specify the message directly or read the message from a file.
        #quota_exceeded_message = Quota exceeded, please try again later.
        #quota_exceeded_message = </path/to/quota_exceeded_message.txt

        # Plugin: expire.
        #expire = Trash 7 Trash/* 7 Junk 30
        #expire_dict = proxy::expire

        # ACL and share folder
        acl = vfile
        acl_shared_dict = proxy::acl

        # By default Dovecot doesn't allow using the IMAP "anyone" or
        # "authenticated" identifier, because it would be an easy way to spam
        # other users in the system. If you wish to allow it,
        #acl_anyone = allow

        # Pigeonhole managesieve service.
        # Reference: http://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
        # Per-user sieve settings.
        sieve_dir = ~/sieve
        sieve = ~/sieve/dovecot.sieve

        # Global sieve settings.
        sieve_global_dir = /hdd/vmail/sieve
        # Note: if user has personal sieve script, global sieve rules defined in
        #       sieve_default will be ignored. Please use sieve_before or
        #       sieve_after instead.
        #sieve_default =

        sieve_before = /hdd/vmail/sieve/dovecot.sieve
        #sieve_after =

        # The maximum number of redirect actions that can be performed during a
        # single script execution.
        # The meaning of 0 differs based on your version. For pigeonhole-0.3.0 and
        # beyond this means that redirect is prohibited. For older versions,
        # however, this means that the number of redirects is unlimited.
        sieve_max_redirects = 30

        # Use recipient as vacation message sender instead of null sender (<>).
        sieve_vacation_send_from_recipient = yes

        # Reference: http://wiki2.dovecot.org/Plugins/MailboxAlias
        mailbox_alias_old = Sent
        mailbox_alias_new = Sent Messages
        mailbox_alias_old2 = Sent
        mailbox_alias_new2 = Sent Items

        # Events to log. `autoexpunge` is included in `expunge`
        # Defined in https://github.com/dovecot/core/blob/ma … g-plugin.c
        mail_log_events = delete undelete expunge mailbox_delete mailbox_rename
        mail_log_fields = uid box msgid size from subject

        # stats
        #
        # how often to session statistics (must be set)
        stats_refresh = 30 secs
        # track per-IMAP command statistics (optional)
        stats_track_cmds = yes
        # Last Login Plugin
        last_login_dict = proxy::lastlogin
        last_login_key = last-login/%s/%u/%d
    }

    service stats {
        fifo_listener stats-mail {
            user = vmail
            mode = 0644
        }

        inet_listener {
            address = 127.0.0.1
            port = 24242
        }
    }

    service quota-warning {
        executable = script /usr/local/bin/dovecot-quota-warning.sh
        unix_listener quota-warning {
            user = vmail
            group = vmail
            mode = 0660
        }
    }

    service dict {
        unix_listener dict {
            mode = 0660
            user = vmail
            group = vmail
        }
    }

    dict {
        #expire = db:/var/lib/dovecot/expire/expire.db
        quotadict = mysql:/etc/dovecot/dovecot-used-quota.conf
        acl = mysql:/etc/dovecot/dovecot-share-folder.conf
        lastlogin = mysql:/etc/dovecot/dovecot-last-login.conf
    }

    protocol lda {
        # Reference: http://wiki2.dovecot.org/LDA
        mail_plugins = $mail_plugins sieve
        lda_mailbox_autocreate = yes
        lda_mailbox_autosubscribe = yes

        # Log file path if we use internal log system
        #log_path = /var/log/dovecot/sieve.log
    }

    protocol lmtp {
        # Log file path if we use internal log system
        #log_path = /var/log/dovecot/lmtp.log

        # Plugins
        mail_plugins = quota sieve

        # Address extension delivery
        lmtp_save_to_detail_mailbox = yes
        recipient_delimiter = +
    }

    protocol imap {
        mail_plugins = $mail_plugins imap_quota imap_acl imap_stats last_login
        imap_client_workarounds = tb-extra-mailbox-sep

        # Maximum number of IMAP connections allowed for a user from each IP address.
        # NOTE: The username is compared case-sensitively.
        # Default is 10.
        # Increase it to avoid issue like below:
        # "Maximum number of concurrent IMAP connections exceeded"
        mail_max_userip_connections = 30
    }

    protocol pop3 {
        mail_plugins = $mail_plugins last_login
        pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
        pop3_uidl_format = %08Xu%08Xv

        # Maximum number of IMAP connections allowed for a user from each IP address.
        # NOTE: The username is compared case-sensitively.
        # Default is 10.
        mail_max_userip_connections = 30

        # POP3 logout format string:
        #  %i - total number of bytes read from client
        #  %o - total number of bytes sent to client
        #  %t - number of TOP commands
        #  %p - number of bytes sent to client as a result of TOP command
        #  %r - number of RETR commands
        #  %b - number of bytes sent to client as a result of RETR command
        #  %d - number of deleted messages
        #  %m - number of messages (before deletion)
        #  %s - mailbox size in bytes (before deletion)
        # Default format doesn't have 'in=%i, out=%o'.
        #pop3_logout_format = top=%t/%p, retr=%r/%b, del=%d/%m, size=%s, in=%i, out=%o
    }

    # Login processes. Refer to Dovecot wiki for more details:
    # http://wiki2.dovecot.org/LoginProcess
    service imap-login {
        #inet_listener imap {
        #    port = 143
        #}
        #inet_listener imaps {
        #    port = 993
        #    ssl = yes
        #}

        service_count = 1

        # To avoid startup latency for new client connections, set process_min_avail
        # to higher than zero. That many idling processes are always kept around
        # waiting for new connections.
        #process_min_avail = 0

        # number of simultaneous IMAP connections
        process_limit = 500

        # vsz_limit should be fine at its default 64MB value
        #vsz_limit = 64M
    }

    service pop3-login {
        #inet_listener pop3 {
        #    port = 110
        #}
        #inet_listener pop3s {
        #    port = 995
        #    ssl = yes
        #}

        service_count = 1

        # number of simultaneous POP3 connections
        #process_limit = 500
    }

    service managesieve-login {
        inet_listener sieve {
            # Listen on localhost (ipv4)
            address = 127.0.0.1
            port = 4190
        }
    }

    namespace {
        type = private
        separator = /
        prefix =
        inbox = yes

        # Refer to document for more details about alias mailbox:
        # http://wiki2.dovecot.org/MailboxSettings
        #
        # Sent
        mailbox Sent {
            auto = subscribe
            special_use = \Sent
        }
        mailbox "Sent Messages" {
            auto = no
            special_use = \Sent
        }
        mailbox "Sent Items" {
            auto = no
            special_use = \Sent
        }

        mailbox Drafts {
            auto = subscribe
            special_use = \Drafts
        }

        # Trash
        mailbox Trash {
            auto = subscribe
            special_use = \Trash
        }

        mailbox "Deleted Messages" {
            auto = no
            special_use = \Trash
        }

        # Junk
        mailbox Junk {
            auto = subscribe
            special_use = \Junk
        }
        mailbox Spam {
            auto = no
            special_use = \Junk
        }
        mailbox "Junk E-mail" {
            auto = no
            special_use = \Junk
        }

        # Archive
        mailbox Archive {
            auto = no
            special_use = \Archive
        }
        mailbox Archives {
            auto = no
            special_use = \Archive
        }
    }

    namespace {
        type = shared
        separator = /
        prefix = Shared/%%u/
        location = maildir:%%Lh/Maildir/:INDEX=%%Lh/Maildir/Shared/%%Ld/%%Ln

        # this namespace should handle its own subscriptions or not.
        subscriptions = yes
        list = children
    }

    # Public mailboxes.
    # Refer to Dovecot wiki page for more details:
    # http://wiki2.dovecot.org/SharedMailboxes/Public
    #namespace {
    #    type = public
    #    separator = /
    #    prefix = Public/
    #    location = maildir:/hdd/vmail/public:CONTROL=%Lh/Maildir/public:INDEXPVT=%Lh/Maildir/public
    #
    #    # Allow users to subscribe to the public folders.
    #    subscriptions = yes
    #}

    !include_try /etc/dovecot/iredmail/*.conf

4

Re: Lost connection to mail dir -Dovecot Authentication failure

The last dovecot.conf is fine. Do you still have the issue?

5 (edited by petero 2021-08-23 18:49:53)

Re: Lost connection to mail dir -Dovecot Authentication failure

Hi,
No same issue - dovecot does not connect to mailbox. Postfix functions,sending and receiving from its interface.

error msg:
doveconf: Warning: NOTE: You can get a new clean config file with: doveconf -Pn > dovecot-new.conf
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:42: ssl_protocols has been replaced by ssl_min_protocol
doveconf: Error: Could not find a minimum ssl_min_protocol setting from ssl_protocols = !SSLv2 !SSLv3: Unrecognized protocol 'SSLv2'
doveadm(petero): Error: net_connect_unix(/var/run/dovecot/stats-writer) failed: Permission denied
Fatal: Plugin 'stats' not found from directory /usr/lib/dovecot/modules
===============
File "/usr/lib/python3/dist-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'iredapd'@'localhost'
(using password: YES)")
-----------mail log=======
Aug 22 18:21:41 server postfix/smtpd[49848]: warning: problem talking to server 127.0.0.1:12340: Connection refused
Aug 22 18:21:42 server postfix/smtpd[49848]: warning: connect to 127.0.0.1:12340: Connection refused
Aug 22 18:21:42 server postfix/smtpd[49848]: warning: problem talking to server 127.0.0.1:12340: Connection refused
============
output: lda(postmaster@perseus.stormpetrel.net): Error: net_connect_unix(/var/run/dovecot/stats-writer) failed: Permission denied )
=============
I added this
service stats {
    unix_listener stats-reader {
        user = vmail
        group = vmail
        mode = 0660
    }

    unix_listener stats-writer {
        user = vmail
        group = vmail
        mode = 0660
    }
}
No error messagesnow but SoGo still showing"no mailbox selected"

Peter

6

Re: Lost connection to mail dir -Dovecot Authentication failure

Solved - installed iredmail  ON ANOTHER BOX and copied the dovecot.conf file over to problem install
and it ran correctly.

Peter