Skip to content

Instantly share code, notes, and snippets.

@cosmomill
Last active February 8, 2023 20:13
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cosmomill/4668341 to your computer and use it in GitHub Desktop.
Save cosmomill/4668341 to your computer and use it in GitHub Desktop.
Dead Simple Postfix/Dovecot Config for Froxlor
driver = mysql
connect = host=127.0.0.1 dbname=froxlor user=froxlor password=secret
default_pass_scheme = CRYPT
password_query = SELECT username AS user, password_enc AS password, CONCAT(homedir, maildir) AS userdb_home, uid AS userdb_uid, gid AS userdb_gid, CONCAT('mdbox:', homedir, maildir) AS userdb_mail, CONCAT('*:storage=', (quota*1024)) as userdb_quota_rule FROM mail_users WHERE (username = '%u' OR email = '%u') AND ((imap = 1 AND '%Ls' = 'imap') OR (pop3 = 1 AND '%Ls' = 'pop3') OR '%Ls' = 'smtp')
user_query = SELECT CONCAT(homedir, maildir) AS home, CONCAT('mdbox:', homedir, maildir) AS mail, uid, gid, CONCAT('*:storage=', (quota*1024)) as quota_rule FROM mail_users WHERE (username = '%u' OR email = '%u')
# The iterate_query is required for the doveadm command and works only on dovecot 2 servers.
iterate_query = SELECT username AS user FROM mail_users
base_dir = /var/run/dovecot/
protocols = pop3 imap lmtp
disable_plaintext_auth = no
mail_plugins = quota
#ssl = yes
#ssl_cert = </etc/ssl/dovecot/cert.pem
#ssl_key = </etc/ssl/dovecot/key.pem
mail_privileged_group = vmail
auth_mechanisms = plain login
auth_failure_delay = 10
auth_cache_size = 5M
auth_cache_negative_ttl = 300
passdb {
args = /etc/dovecot/dovecot-sql.conf
driver = sql
}
userdb {
driver = prefetch
}
userdb {
args = /etc/dovecot/dovecot-sql.conf
driver = sql
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
unix_listener auth-master {
group = vmail
mode = 0660
user = vmail
}
user = vmail
}
service auth-worker {
unix_listener auth-worker {
group = vmail
mode = 0660
user = vmail
}
user = vmail
}
service imap-login {
service_count = 0
process_min_avail = 1
process_limit = 2
vsz_limit = 256M
}
protocol imap {
imap_client_workarounds = delay-newmail tb-extra-mailbox-sep
mail_plugins = $mail_plugins imap_quota
}
service pop3-login {
service_count = 0
process_min_avail = 1
process_limit = 2
vsz_limit = 256M
}
protocol pop3 {
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
pop3_uidl_format = %08Xu%08Xv
mail_plugins = $mail_plugins
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0660
user = postfix
}
}
protocol lmtp {
mail_plugins = $mail_plugins
}
plugin {
quota = dict:User quota::file:%h/dovecot-quota
}
biff = no
append_dot_mydomain = no
message_size_limit = 0
mailbox_size_limit = 0
myhostname = mail.example.com
mydomain = $myhostname
mydestination = $myhostname, localhost, localhost.$mydomain
mynetworks = 127.0.0.0/8
proxy_read_maps =
proxy:unix:passwd.byname
$relay_domains
$virtual_alias_maps
$transport_maps
relay_domains = proxy:mysql:/etc/postfix/mysql-relay_domains.cf
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_alias.cf
transport_maps = proxy:mysql:/etc/postfix/mysql-transport.cf
strict_rfc821_envelopes = yes
disable_vrfy_command = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain = $myhostname
smtpd_helo_required = yes
smtpd_recipient_restrictions =
reject_unknown_recipient_domain,
reject_non_fqdn_recipient,
permit_mynetworks,
permit_sasl_authenticated,
reject_unverified_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
permit
smtpd_sender_restrictions =
permit_mynetworks,
reject_sender_login_mismatch,
permit_sasl_authenticated,
reject_unknown_helo_hostname,
reject_unknown_recipient_domain,
reject_unknown_sender_domain
smtpd_client_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unknown_client_hostname
# enable tls support
#smtpd_use_tls = yes
#smtpd_tls_key_file = /ssl/postfix/key.pem
#smtpd_tls_cert_file = /etc/ssl/postfix/cert.pem
#smtpd_tls_CAfile = /ssl/postfix/cacert.pem
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#smtp inet n - n - 1 postscreen
#smtpd pass - - n - - smtpd
#dnsblog unix - - n - 0 dnsblog
#tlsproxy unix - - n - 0 tlsproxy
submission inet n - n - - smtpd
# -o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - n - - qmqpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - n 300 1 oqmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay unix - - n - - smtp
-o smtp_fallback_relay=
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
user = froxlor
password = secret
hosts = 127.0.0.1
dbname = froxlor
query = SELECT 1 FROM panel_domains WHERE domain='%s' AND isemaildomain=1 AND deactivated=0
user = froxlor
password = secret
hosts = 127.0.0.1
dbname = froxlor
query = SELECT 'lmtp:unix:private/dovecot-lmtp' FROM panel_domains WHERE domain='%s'
user = froxlor
password = secret
hosts = 127.0.0.1
dbname = froxlor
query = SELECT destination FROM mail_virtual WHERE email='%s' AND CHAR_LENGTH(TRIM(destination))>0
@jult
Copy link

jult commented Feb 8, 2023

This fails. Your values require units.
auth_failure_delay = 10
for example needs an s. This goes for ALL dovecot values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment