Simple yet functional dovecot+postfix

This commit is contained in:
Pierre Jaury
2016-02-17 22:56:40 +01:00
parent 508c741ffa
commit 47272df96b
24 changed files with 195 additions and 278 deletions

View File

@@ -1,33 +1,43 @@
# aliases
sql = pgsql:${config_directory}/
proxysql = proxy:${sql}
###############
# General
###############
# relocated users from the database
relocated_maps = ${proxysql}pgsql-relocated_maps.cf
# The list of relayed networks is still loaded from a configuration file
mynetworks = /data/relaynets
# Empty alias list to override the configuration variable and disable NIS
alias_maps = hash:/etc/aliases
# SQLite configuration
sql = sqlite:${config_directory}/
# transport settings from our database
transport_maps = ${proxysql}pgsql-transport_maps.cf
###############
# TLS
###############
smtpd_use_tls = yes
smtpd_tls_cert_file=/data/ssl/cert.pem
smtpd_tls_key_file=/data/ssl/key.pem
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# virtual domains, mailboxes and aliases
virtual_mailbox_domains = ${proxysql}pgsql-virtual_mailbox_domains.cf
virtual_alias_maps = ${proxysql}pgsql-virtual_alias_maps.cf
virtual_minimum_uid = 70000
virtual_uid_maps = ${sql}pgsql-virtual_uid_maps.cf
virtual_gid_maps = ${sql}pgsql-virtual_gid_maps.cf
virtual_mailbox_base = /
virtual_mailbox_maps = ${proxysql}pgsql-virtual_mailbox_maps.cf
# delivery transport
virtual_transport = lmtp:unix:private/dovecot-lmtp
# dovecot SASL
###############
# SASL
###############
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/dovecot-auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noplaintext, noanonymous
smtpd_sasl_security_options = noanonymous
# submission restrictions
smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
###############
# Virtual
###############
virtual_mailbox_domains = ${sql}sqlite-virtual_mailbox_domains.cf
virtual_alias_maps = ${sql}sqlite-virtual_alias_maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
###############
# Milter
###############
milter_default_action = tempfail
milter_protocol = 6
smtpd_milters =
non_smtpd_milters =

View File

@@ -1,33 +1,18 @@
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# main SMTP services
# Exposed SMTP services
smtp inet n - - - - smtpd
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_enforce_tls=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_reject_unlisted_recipient=no
-o smtpd_client_restrictions=$mua_client_restrictions
-o smtpd_helo_restrictions=$mua_helo_restrictions
-o smtpd_sender_restrictions=$mua_sender_restrictions
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
smtps inet n - - - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_enforce_tls=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_reject_unlisted_recipient=no
-o smtpd_client_restrictions=$mua_client_restrictions
-o smtpd_helo_restrictions=$mua_helo_restrictions
-o smtpd_sender_restrictions=$mua_sender_restrictions
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
# internal postfix services
pickup unix n - - 60 1 pickup
# Internal postfix services
cleanup unix n - - - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - - 1000? 1 tlsmgr
@@ -35,18 +20,14 @@ rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
proxymap unix - - - - - proxymap
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT destination FROM postfix_relocated_map('%u', '%d')

View File

@@ -1,18 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# XXX see create_optional_types_and_functions.pgsql
# * line 9: type sender_login
# * line 26: function postfix_smtpd_sender_login_map + comment above
#
# The SQL query template used to search the database
query = SELECT login FROM postfix_smtpd_sender_login_map('%u', '%d')

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT transport FROM postfix_transport_map('%u', '%d')

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT destination FROM postfix_virtual_alias_map('%u', '%d')

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT gid FROM postfix_gid WHERE domainname='%d'

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT gid FROM postfix_gid WHERE domainname='%s'

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT maildir FROM postfix_virtual_mailbox_map('%u', '%d')

View File

@@ -1,14 +0,0 @@
# All parameters are described in pgsql_table(5) / PGSQL PARAMETERS
#
# The hosts that Postfix will try to connect to and query from.
hosts = localhost
# The user name and password to log into the pgsql server.
user = postfix
password = some_password
# The database name on the servers.
dbname = mailsys
# The SQL query template used to search the database
query = SELECT uid FROM postfix_virtual_uid_map('%u', '%d')

View File

@@ -0,0 +1,2 @@
dbpath = /data/freeposte.db
query = SELECT destination FROM aliases WHERE localpart = '%u' AND domain = '%d'

View File

@@ -0,0 +1,2 @@
dbpath = /data/freeposte.db
query = SELECT domain FROM domains WHERE domain='%s'