1

I tried setting up Postfix 2.10/Dovecot 2.2 email server for my domain on my CentOS 7 VPS, but I have met my match and must defer to the internet. I am using Nginx and MariaDB with PostfixAdmin, and will be using Roundcube for webmail (but first things first). Postfix is using virtual mailboxes, stored in /var/www/mail/vmail.

I must confess that in my search for help I have visited quite literally scores of sites, and my configuration files may have degenerated into what might now be nonsensical in places; apologies in advance.

I'm getting error status deferred when I try to send a mail with sudo echo Subject: sendmail test" | sendmail -v recipient@verizon.net. I can post the other /etc/dovecot/conf.d/ logs if need be.

/var/log/maillog:

Sep 22 14:04:08 hwsrv-579344 postfix/pickup[15245]: 20D8146379C: uid=1000 from=<contos_user>
Sep 22 14:04:08 hwsrv-579344 postfix/cleanup[20958]: 20D8146379C: message-id=<20190922140408.20D8146379C@mail.example.com>
Sep 22 14:04:08 hwsrv-579344 postfix/qmgr[15246]: 20D8146379C: from=<user@example.com>, size=288, nrcpt=1 (queue active)
Sep 22 14:04:08 hwsrv-579344 postfix/smtp[20967]: Untrusted TLS connection established to mx-aol.mail.gm0.yahoodns.net[67.195.204.80]:25: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Sep 22 14:04:08 hwsrv-579344 postfix/smtp[20967]: 20D8146379C: to=<recipient@verizon.net>, relay=mx-aol.mail.gm0.yahoodns.net[67.195.204.80]:25, delay=3.4, delays=2.7/0.02/0.42/0.21, dsn=5.7.5, status=bounced (host mx-aol.mail.gm0.yahoodns.net[67.195.204.80] said: 556 5.7.5 Invalid RFC missing body (in reply to end of DATA command))
Sep 22 14:04:08 hwsrv-579344 postfix/cleanup[20958]: D124A4637A2: message-id=<20190922140408.D124A4637A2@mail.example.com>
Sep 22 14:04:08 hwsrv-579344 postfix/qmgr[15246]: D124A4637A2: from=<>, size=2259, nrcpt=1 (queue active)
Sep 22 14:04:08 hwsrv-579344 postfix/bounce[20969]: 20D8146379C: sender non-delivery notification: D124A4637A2
Sep 22 14:04:08 hwsrv-579344 postfix/cleanup[20958]: D443F463820: message-id=<20190922140408.D443F463820@mail.example.com>
Sep 22 14:04:08 hwsrv-579344 postfix/bounce[20970]: 20D8146379C: sender delivery status notification: D443F463820
Sep 22 14:04:08 hwsrv-579344 postfix/qmgr[15246]: 20D8146379C: removed
Sep 22 14:04:08 hwsrv-579344 postfix/qmgr[15246]: D443F463820: from=<>, size=2080, nrcpt=1 (queue active)
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(20972): Connect from local
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(20976): Connect from local
Sep 22 14:04:08 hwsrv-579344 dovecot: auth: Fatal: sql /etc/dovecot/conf.d/dovecot-sql.conf.ext: Can't open configuration file /etc/dovecot/conf.d/dovecot-sql.conf.ext: No such file or directory
Sep 22 14:04:08 hwsrv-579344 dovecot: master: Error: service(auth): command startup failed, throttling for 32 secs
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(user@example.com): Error: userdb lookup(user@example.com): Disconnected unexpectedly
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(user@example.com): Error: userdb lookup(user@example.com): Disconnected unexpectedly
Sep 22 14:04:08 hwsrv-579344 postfix/lmtp[20971]: D124A4637A2: to=<user@example.com>, relay=mail.example.com[private/dovecot-lmtp], delay=0.08, delays=0.01/0.01/0.01/0.04, dsn=4.3.0, status=deferred (host mail.example.com[private/dovecot-lmtp] said: 451 4.3.0 <user@example.com> Internal error occurred. Refer to server log for more information. (in reply to RCPT TO command))
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(20972): Disconnect from local: Successful quit
Sep 22 14:04:08 hwsrv-579344 postfix/lmtp[20973]: D443F463820: to=<user@example.com>, relay=mail.example.com[private/dovecot-lmtp], delay=0.07, delays=0.01/0.01/0.01/0.04, dsn=4.3.0, status=deferred (host mail.example.com[private/dovecot-lmtp] said: 451 4.3.0 <user@example.com> Internal error occurred. Refer to server log for more information. (in reply to RCPT TO command))
Sep 22 14:04:08 hwsrv-579344 dovecot: lmtp(20976): Disconnect from local: Successful quit

/etc/dovecot/dovecot.conf:

!include conf.d/*.conf
!include_try /usr/share/dovecot/protocols.d/*.protocol
!include conf.d/auth-sql.conf.ext

protocols = "imap pop3 lmtp"

login_greeting = My Mail Server
auth_mechanisms = plain login

namespace inbox {
  type = private
  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 =
}

mail_home = /var/www/mail/vmail/%d/%n
mail_location = maildir:~

ssl = yes
ssl_cert = </etc/ssl/private/vmail.crt
ssl_key = </etc/ssl/private/vmail.key

/etc/dovecot/dovecot-mysql.conf:

driver = mysql
connect = host=localhost dbname=postfix_db user=dovecot  password=tr=&He4toSw!crUBi$iq
default_pass_scheme = SHA512-CRYPT
user_query = SELECT '/var/www/mail/vmail/%d/%u' as home, 'maildir:/var/vmail/%d/%u' as mail, 2000 AS uid, 8 AS gid, concat('dirsize:storage=',  quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
password_query = SELECT username as user, password, '/var/www/mail/vmail/%d/%n' as userdb_home, 'maildir:/var/vmail/%d/%n' as userdb_mail, 2000 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'

/etc/dovecot/conf.d/10-master.conf

service imap-login {
    inet_listener imap {
        #port = 143
    }

    inet_listener imaps {
        #port = 993
        #ssl = yes
    }
}

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

service lmtp {
    unix_listener /var/spool/postfix/private/dovecot-lmtp {
        mode = 0600
        user = postfix
        group = postfix
    }

    inet_listener lmtp {
        # Avoid making LMTP visible for the entire internet
        address = 127.0.0.1
        port = 2424
    }
}

service imap {
    process_limit = 1024
}

service pop3 {
    process_limit = 1024
}

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

service auth-worker {
    #user = root
}

service dict {
    user = vmail
}

/etc/postfix/main.cf

mail_owner                   = postfix
myhostname                   = mail.example.com
mydomain                     = example.com
myorigin                     = $mydomain
inet_interfaces              = all
inet_protocols               = all
mydestination                = $myhostname, localhost, localhost.$mydomain
alias_maps                   = hash:/etc/aliases
alias_database               = hash:/etc/aliases
home_mailbox                 = Maildir/
smtpd_banner                 = $myhostname ESMTP $mail_name (CentOS)
biff                         = no
readme_directory             = /usr/share/doc/postfix-2.10.1/README_FILES
append_dot_mydomain          = no
broken_sasl_auth_clients     = yes
mailbox_size_limit           = 0
smtp_tls_security_level      = may
smtp_tls_loglevel            = 1

smtpd_helo_required          = yes 
smtpd_recipient_restrictions = permit_sasl_authenticated, 
                               permit_mynetworks,
                               reject_unauth_destination
smtpd_relay_restrictions     = permit_mynetworks,
                               permit_sasl_authenticated, 
                               defer_unauth_destination
smtpd_sasl_auth_enable       = yes
smtpd_sasl_local_domain      = $mydomain
smtpd_sasl_path              = /run/dovecot/auth-client
smtpd_sasl_security_options  = noanonymous,
                               noplaintext
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type              = dovecot
smtpd_tls_auth_only          = yes
smtpd_tls_CAfile             = /etc/ssl/private/fullchain.pem
smtpd_tls_cert_file          = /etc/ssl/private/fullchain.pem
smtpd_tls_key_file           = /etc/ssl/private/vmail.key
smtpd_tls_loglevel           = 1
smtpd_tls_received_header    = yes
smtpd_tls_security_level     = may
smtpd_use_tls                = yes

virtual_alias_maps           = mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_gid_maps             = static:2000
virtual_mailbox_base         = /var/www/mail/vmail
virtual_mailbox_domains      = mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_limit        = 512000000
virtual_mailbox_maps         = mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_minimum_uid          = 2000
virtual_transport            = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps             = static:2000
local_transport              = virtual
transport_maps               = hash:/etc/postfix/transport

Thanks in advance for any light that can be shed on this.

SKNB
  • 25
  • 1
  • 10
  • 2
    You can dump all non-default dovecot config using `doveconf -n`, which should pinpoint your `/etc/dovecot/dovecot-mysql.conf` path mismatch. Please test with a complete mail (use a tool such as `mime-construct` if unsure how to). – anx Sep 22 '19 at 16:23
  • See this error message from your log: "Sep 22 14:04:08 hwsrv-579344 dovecot: auth: Fatal: sql /etc/dovecot/conf.d/dovecot-sql.conf.ext: Can't open configuration file /etc/dovecot/conf.d/dovecot-sql.conf.ext: No such file or directory". Dovecot is not configured properly, it is directed to include a file which doesn't exists or isn't readable. Did you checked this? – Nikita Kipriyanov Sep 23 '19 at 08:35
  • Thank you for your help! You're correct, it was the Dovecot and reinstalling it from scratch got rid of the errors. – SKNB Oct 06 '19 at 21:17
  • Looks like this has been resolved, but still lacks a definite answer. – anx Aug 03 '23 at 03:29

0 Answers0