Почтовый сервер на Debian 9 полная установка: dbmail & postgresql & postfix & stunnel & postgrey& spamassassin: различия между версиями

Материал из support.qbpro.ru
imported>Vix
Нет описания правки
imported>Vix
Нет описания правки
Строка 59: Строка 59:
* пример рабочего конфигурационного файла:
* пример рабочего конфигурационного файла:


# (c) 2000-2006 IC&S, The Netherlands  
# (c) 2000-2006 IC&S, The Netherlands  
#
#
# Configuration file for DBMAIL  
# Configuration file for DBMAIL  
[DBMAIL]  
[DBMAIL]  
#  
#  
# Database settings
# Database settings
#
#
# database connection URI
# database connection URI
#dburi                = sqlite:///var/tmp/dbmail.db
#dburi                = sqlite:///var/tmp/dbmail.db
#  
#  
# Supported drivers are sql, ldap.
# Supported drivers are sql, ldap.
#
#
authdriver          = sql
authdriver          = sql
#  
#  
#  
#  
# following fields are now DEPRECATED!
# following fields are now DEPRECATED!
driver              = postgresql
driver              = postgresql
host                = 10.0.5.2
host                = 10.0.5.2
sqlport              = 5432
sqlport              = 5432
#sqlsocket            =               
#sqlsocket            =               
user                = dbmail
user                = dbmail
pass                = dbmailpass
pass                = dbmailpass
db                  = mailbasename
db                  = mailbasename
#
#
# Number of database connections per threaded daemon
# Number of database connections per threaded daemon
# This also determines the size of the worker threadpool
# This also determines the size of the worker threadpool
#
#
# Do NOT increase this without proper consideration. A
# Do NOT increase this without proper consideration. A
# very large database/worker pool will not only increase
# very large database/worker pool will not only increase
# the connection pressure on the database, but will more
# the connection pressure on the database, but will more
# significantly cause unnecessary context-switching in  
# significantly cause unnecessary context-switching in  
# your CPUs.
# your CPUs.
#
#
#max_db_connections  = 10
#max_db_connections  = 10
#  
#  
# Table prefix. Defaults to "dbmail_" if not specified.
# Table prefix. Defaults to "dbmail_" if not specified.
#
#
table_prefix        = dbmail_   
table_prefix        = dbmail_   
#  
#  
# encoding must match the database/table encoding.
# encoding must match the database/table encoding.
# i.e. latin1, utf8
# i.e. latin1, utf8
encoding            = utf8
encoding            = utf8
#
#
# messages with unknown encoding will be assumed to have  
# messages with unknown encoding will be assumed to have  
# default_msg_encoding
# default_msg_encoding
# i.e. iso8859-1, utf8
# i.e. iso8859-1, utf8
default_msg_encoding = utf8
default_msg_encoding = utf8
#  
#  
# Postmaster's email address for use in bounce messages.
# Postmaster's email address for use in bounce messages.
#
#
#postmaster          = DBMAIL-MAILER       
#postmaster          = DBMAIL-MAILER       
#  
#  
# Sendmail executable for forwards, replies, notifies, vacations.
# Sendmail executable for forwards, replies, notifies, vacations.
# You may use pipes (|) in this command, for example:
# You may use pipes (|) in this command, for example:
# dos2unix|/usr/sbin/sendmail  works well with Qmail.
# dos2unix|/usr/sbin/sendmail  works well with Qmail.
# You may use quotes (") for executables with unusual names.
# You may use quotes (") for executables with unusual names.
#
#
sendmail              = /usr/sbin/sendmail     
sendmail              = /usr/sbin/sendmail     
#
#
#
#
# The following items can be overridden in the service-specific sections.
# The following items can be overridden in the service-specific sections.
#
#
#
#
#
#
# Logging via stderr/log file and syslog
# Logging via stderr/log file and syslog
#
#
# Logging is broken up into 8 logging levels and each level can be indivually turned on or off.
# Logging is broken up into 8 logging levels and each level can be indivually turned on or off.
# The Stderr/log file logs all entries to stderr or the log file.
# The Stderr/log file logs all entries to stderr or the log file.
# Syslog logging uses the facility mail and the logging level of the event for logging.
# Syslog logging uses the facility mail and the logging level of the event for logging.
# Syslog can then be configured to log data according to the levels.
# Syslog can then be configured to log data according to the levels.
#
#
# Set the log level to the sum of the values next to the levels you want to record.
# Set the log level to the sum of the values next to the levels you want to record.
#  1 = Emergency  
#  1 = Emergency  
#  2 = Alert
#  2 = Alert
#  4 = Critical
#  4 = Critical
#  8 = Error
#  8 = Error
#  16 = Warning
#  16 = Warning
#  32 = Notice
#  32 = Notice
#  64 = Info
#  64 = Info
# 128 = Debug
# 128 = Debug
# 256 = Database -> Logs at debug level
# 256 = Database -> Logs at debug level
#
#
# Examples:  0 = Nothing
# Examples:  0 = Nothing
#            31 = Emergency + Alert + Critical + Error + Warning
#            31 = Emergency + Alert + Critical + Error + Warning
#          511 = Everything
#          511 = Everything
#
#
file_logging_levels      = 7
file_logging_levels      = 7
#
#
syslog_logging_levels    = 31
syslog_logging_levels    = 31
#
#
# Generate a log entry for database queries for the log level at number of seconds of query execution time.
# Generate a log entry for database queries for the log level at number of seconds of query execution time.
#
#
query_time_info      = 10
query_time_info      = 10
query_time_notice    = 20
query_time_notice    = 20
query_time_warning    = 30
query_time_warning    = 30
#
#
# Throw an exception is the query takes longer than query_timeout seconds
# Throw an exception is the query takes longer than query_timeout seconds
query_timeout        = 300  
query_timeout        = 300  
#  
#  
# Root privs are used to open a port, then privs
# Root privs are used to open a port, then privs
# are dropped down to the user/group specified here.
# are dropped down to the user/group specified here.
#
#
effective_user        = dbmail
effective_user        = dbmail
effective_group      = mail
effective_group      = mail
#  
#  
# The IPv4 and/or IPv6 addresses the services will bind to.
# The IPv4 and/or IPv6 addresses the services will bind to.
# Use * for all local interfaces.
# Use * for all local interfaces.
# Use 127.0.0.1 for localhost only.
# Use 127.0.0.1 for localhost only.
# Separate multiple entries with spaces ( ) or commas (,).
# Separate multiple entries with spaces ( ) or commas (,).
#
#
bindip                = 0.0.0.0        # IPv4 only - all IP's
bindip                = 0.0.0.0        # IPv4 only - all IP's
#bindip                = ::            # IPv4 and IPv6 - all IP's (linux)
#bindip                = ::            # IPv4 and IPv6 - all IP's (linux)
#bindip                = ::            # IPv6 only - all IP's (BSD)
#bindip                = ::            # IPv6 only - all IP's (BSD)
#bindip                = 0.0.0.0,::    # IPv4 and IPv6 - all IP's (BSD)
#bindip                = 0.0.0.0,::    # IPv4 and IPv6 - all IP's (BSD)
#
#
# The maximum length of the queue of pending connections. See
# The maximum length of the queue of pending connections. See
# listen(2) for more information
# listen(2) for more information
#
#
# backlog              = 128
# backlog              = 128
#  
#  
# Idle time allowed before a connection is shut off.
# Idle time allowed before a connection is shut off.
#
#
timeout              = 300             
timeout              = 300             
#  
#  
# Idle time allowed before a connection is shut off if you have not logged in yet.
# Idle time allowed before a connection is shut off if you have not logged in yet.
#
#
login_timeout        = 60
login_timeout        = 60
#  
#  
# If yes, resolves IP addresses to DNS names when logging.
# If yes, resolves IP addresses to DNS names when logging.
#
#
resolve_ip            = yes
resolve_ip            = yes
#
#
# If yes, keep statistics in the authlog table for connecting users
# If yes, keep statistics in the authlog table for connecting users
#
#
authlog              = no
authlog              = no
#  
#  
# logfile for stdout messages
# logfile for stdout messages
#
#
logfile              = /var/log/dbmail.log         
logfile              = /var/log/dbmail.log         
#  
#  
# logfile for stderr messages
# logfile for stderr messages
#
#
errorlog              = /var/log/dbmail.err         
errorlog              = /var/log/dbmail.err         
#  
#  
# directory for storing PID files
# directory for storing PID files
#
#
pid_directory        = /var/run/dbmail
pid_directory        = /var/run/dbmail
#
#
# directory for locating libraries (normally has a sane default compiled-in)
# directory for locating libraries (normally has a sane default compiled-in)
#
#
library_directory      = /usr/lib/dbmail
library_directory      = /usr/lib/dbmail
#
#
# SSL/TLS certificates
# SSL/TLS certificates
#
#
# A file containing a list of CAs in PEM format
# A file containing a list of CAs in PEM format
tls_cafile            =
tls_cafile            =
# A file containing a PEM format certificate
# A file containing a PEM format certificate
tls_cert              =
tls_cert              =
# A file containing a PEM format RSA or DSA key
# A file containing a PEM format RSA or DSA key
tls_key              =
tls_key              =
# A cipher list string in the format given in ciphers(1)
# A cipher list string in the format given in ciphers(1)
tls_ciphers          =
tls_ciphers          =
# hashing algorithm. You can select your favorite hash type
# hashing algorithm. You can select your favorite hash type
# for generating unique ids for message parts.  
# for generating unique ids for message parts.  
#
#
# for valid values check mhash(3) but minus the MHASH_ prefix.
# for valid values check mhash(3) but minus the MHASH_ prefix.
#   
#   
# if you ever change this value run 'dbmail-util --rehash' to  
# if you ever change this value run 'dbmail-util --rehash' to  
# update the hash for all mimeparts.
# update the hash for all mimeparts.
#
#
# examples: MD5, SHA1, SHA256, SHA512, TIGER, WHIRLPOOL
# examples: MD5, SHA1, SHA256, SHA512, TIGER, WHIRLPOOL
#
#
# hash_algorithm = SHA1
# hash_algorithm = SHA1
# header_cache tuning
# header_cache tuning
#
#
# set header_cache_readonly to 'yes' to prevent new
# set header_cache_readonly to 'yes' to prevent new
# unknown header-names from being cached.
# unknown header-names from being cached.
#
#
# header_cache_readonly = yes
# header_cache_readonly = yes
[LMTP]
[LMTP]
bindip = 127.0.0.1
bindip = 127.0.0.1
port                  = 24                 
port                  = 24                 
#tls_port              =
#tls_port              =
[POP]
[POP]
port                  = 110
port                  = 110
#tls_port              = 995
#tls_port              = 995
# You can set an alternate banner to display when connecting to the service
# You can set an alternate banner to display when connecting to the service
# banner = DBMAIL pop3 server ready to rock
# banner = DBMAIL pop3 server ready to rock
#  
#  
# If yes, allows SMTP access from the host IP connecting by POP3.
# If yes, allows SMTP access from the host IP connecting by POP3.
# This requires addition configuration of your MTA
# This requires addition configuration of your MTA
#
#
pop_before_smtp      = no       
pop_before_smtp      = no       
[HTTP]
[HTTP]
port                  = 41380
port                  = 41380
#
#
# the httpd daemon provides full access to all users, mailboxes
# the httpd daemon provides full access to all users, mailboxes
# and messages. Be very careful with this one!
# and messages. Be very careful with this one!
bindip                = 127.0.0.1
bindip                = 127.0.0.1
admin                = admin:secret
admin                = admin:secret
[IMAP]
[IMAP]
# You can set an alternate banner to display when connecting to the service
# You can set an alternate banner to display when connecting to the service
# banner = imap 4r1 server (dbmail 2.3.x)
# banner = imap 4r1 server (dbmail 2.3.x)
#  
#  
# Port to bind to.
# Port to bind to.
#
#
port                  = 143                 
port                  = 143                 
##tls_port              = 993
##tls_port              = 993
#  
#  
# IMAP prefers a longer timeout than other services.
# IMAP prefers a longer timeout than other services.
#
#
timeout              = 4000             
timeout              = 4000             
#  
#  
# If yes, allows SMTP access from the host IP connecting by IMAP.
# If yes, allows SMTP access from the host IP connecting by IMAP.
# This requires addition configuration of your MTA
# This requires addition configuration of your MTA
#
#
imap_before_smtp      = no
imap_before_smtp      = no
#
#
# during IDLE, how many seconds between checking the mailbox
# during IDLE, how many seconds between checking the mailbox
# status (default: 30)
# status (default: 30)
#
#
# idle_timeout          = 30
# idle_timeout          = 30
# during IDLE, how often should the server send an '* OK' still
# during IDLE, how often should the server send an '* OK' still
# here message (default: 10)
# here message (default: 10)
#
#
# the time between such a message is idle_timeout * idle_interval
# the time between such a message is idle_timeout * idle_interval
# seconds
# seconds
#
#
# idle_interval        = 10
# idle_interval        = 10
#
#
# If TLS is enabled, login before starttls is normally
# If TLS is enabled, login before starttls is normally
# not allowed. Use login_disabled=no to change this
# not allowed. Use login_disabled=no to change this
#
#
# login_disabled        = yes
# login_disabled        = yes
#
#
# Provide a CAPABILITY to override the default
# Provide a CAPABILITY to override the default
#
#
# capability            = IMAP4 IMAP4rev1 AUTH=LOGIN ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE
# capability            = IMAP4 IMAP4rev1 AUTH=LOGIN ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE
# max message size. You can specify the maximum message size
# max message size. You can specify the maximum message size
# accepted by the IMAP daemon during APPEND commands.
# accepted by the IMAP daemon during APPEND commands.
#
#
# Supported formats:
# Supported formats:
#  decimal: 1000000     
#  decimal: 1000000     
#  octal:  03777777
#  octal:  03777777
#  hex:    0xfffff
#  hex:    0xfffff
#
#
# max_message_size      =
# max_message_size      =
[SIEVE]
[SIEVE]
#  
#  
# Port to bind to.
# Port to bind to.
#
#
port                  = 2000               
port                  = 2000               
tls_port              =
tls_port              =
[LDAP]
[LDAP]
port                  = 389
port                  = 389
version              = 3
version              = 3
hostname              = ldap
hostname              = ldap
base_dn              = ou=People,dc=mydomain,dc=com
base_dn              = ou=People,dc=mydomain,dc=com
#  
#  
# If your LDAP library supports ldap_initialize(), then you can use the
# If your LDAP library supports ldap_initialize(), then you can use the
# alternative LDAP server DSN like following.
# alternative LDAP server DSN like following.
#
#
# URI                = ldap://127.0.0.1:389
# URI                = ldap://127.0.0.1:389
# URI                = ldapi://%2fvar%2frun%2fopenldap%2fldapi/
# URI                = ldapi://%2fvar%2frun%2fopenldap%2fldapi/
#  
#  
# Leave blank for anonymous bind.
# Leave blank for anonymous bind.
# example: cn=admin,dc=mydomain,dc=com     
# example: cn=admin,dc=mydomain,dc=com     
#
#
bind_dn              =  
bind_dn              =  
#  
#  
# Leave blank for anonymous bind.
# Leave blank for anonymous bind.
#
#
bind_pw              =  
bind_pw              =  
scope                = SubTree
scope                = SubTree
# AD users may want to set this to 'no' to disable
# AD users may want to set this to 'no' to disable
# ldap referrals if you are seeing 'Operations errors'  
# ldap referrals if you are seeing 'Operations errors'  
# in your logs
# in your logs
#
#
referrals            = yes
referrals            = yes
user_objectclass      = top,account,dbmailUser
user_objectclass      = top,account,dbmailUser
forw_objectclass      = top,account,dbmailForwardingAddress
forw_objectclass      = top,account,dbmailForwardingAddress
cn_string            = uid
cn_string            = uid
field_passwd          = userPassword
field_passwd          = userPassword
field_uid            = uid
field_uid            = uid
field_nid            = uidNumber
field_nid            = uidNumber
min_nid              = 10000
min_nid              = 10000
max_nid              = 15000
max_nid              = 15000
field_cid            = gidNumber
field_cid            = gidNumber
min_cid              = 10000
min_cid              = 10000
max_cid              = 15000
max_cid              = 15000
# a comma-separated list of attributes to match when searching
# a comma-separated list of attributes to match when searching
# for users or forwards that match a delivery address. A match
# for users or forwards that match a delivery address. A match
# on any of them is a hit.
# on any of them is a hit.
field_mail            = mail
field_mail            = mail
# field that holds the mail-quota size for a user.
# field that holds the mail-quota size for a user.
field_quota          = mailQuota
field_quota          = mailQuota
# field that holds the forwarding address.  
# field that holds the forwarding address.  
field_fwdtarget      = mailForwardingAddress
field_fwdtarget      = mailForwardingAddress
# override the query string used to search for users  
# override the query string used to search for users  
# or forwards with a delivery address.
# or forwards with a delivery address.
# query_string          = (mail=%s)
# query_string          = (mail=%s)
[DELIVERY]
[DELIVERY]
#  
#  
# Run Sieve scripts as messages are delivered.
# Run Sieve scripts as messages are delivered.
#
#
SIEVE                = yes               
SIEVE                = yes               
#  
#  
# Use 'user+mailbox@domain' format to deliver to a mailbox.
# Use 'user+mailbox@domain' format to deliver to a mailbox.
#
#
SUBADDRESS            = yes           
SUBADDRESS            = yes           
#  
#  
# Turn on/off the Sieve Vacation extension.
# Turn on/off the Sieve Vacation extension.
#
#
SIEVE_VACATION        = yes       
SIEVE_VACATION        = yes       
#  
#  
# Turn on/off the Sieve Notify extension
# Turn on/off the Sieve Notify extension
#
#
SIEVE_NOTIFY          = yes
SIEVE_NOTIFY          = yes
#  
#  
# Turn on/off additional Sieve debugging.
# Turn on/off additional Sieve debugging.
#
#
SIEVE_DEBUG          = no           
SIEVE_DEBUG          = no           
# Use the auto_notify table to send email notifications.
# Use the auto_notify table to send email notifications.
#
#
AUTO_NOTIFY          = no
AUTO_NOTIFY          = no
 
#  
#  
# Use the auto_reply table to send away messages.
# Use the auto_reply table to send away messages.
#
#
AUTO_REPLY            = no
AUTO_REPLY            = no
#  
#  
# Defaults to "NEW MAIL NOTIFICATION"
# Defaults to "NEW MAIL NOTIFICATION"
#
#
#AUTO_NOTIFY_SUBJECT        =     
#AUTO_NOTIFY_SUBJECT        =     
#  
#  
# Defaults to POSTMASTER from the DBMAIL section.
# Defaults to POSTMASTER from the DBMAIL section.
#
#
#AUTO_NOTIFY_SENDER        =   
#AUTO_NOTIFY_SENDER        =   
# If you set this to 'yes' dbmail will check for duplicate
# If you set this to 'yes' dbmail will check for duplicate
# messages in the relevant mailbox during delivery using  
# messages in the relevant mailbox during delivery using  
# the Message-ID header
# the Message-ID header
#
#
suppress_duplicates    = no
suppress_duplicates    = no
#
#
# Soft or hard bounce on over-quota delivery
# Soft or hard bounce on over-quota delivery
#
#
quota_failure          = hard
quota_failure          = hard
# end of configuration file
# end of configuration file
* перезапуск службы:
* перезапуск службы:

Версия от 17:47, 31 октября 2017

Порядок установки:

  • Система Debian Stretch {9}
  • Используемый source.list
# 
deb http://mirror.mephi.ru/debian/ stretch main
deb-src http://mirror.mephi.ru/debian/ stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main 

# stretch-updates, previously known as 'volatile'
deb http://mirror.mephi.ru/debian/ stretch-updates main
deb-src http://mirror.mephi.ru/debian/ stretch-updates main

###### Debian Main Repos
deb http://deb.debian.org/debian/ stable main contrib non-free
deb-src http://deb.debian.org/debian/ stable main contrib non-free

deb http://deb.debian.org/debian/ stable-updates main contrib non-free
deb-src http://deb.debian.org/debian/ stable-updates main contrib non-free

deb http://deb.debian.org/debian-security stable/updates main contrib non-free
deb-src http://deb.debian.org/debian-security stable/updates main contrib non-free

deb http://ftp.debian.org/debian stretch-backports main contrib non-free
deb-src http://ftp.debian.org/debian stretch-backports main contrib non-free

1. Устанавливаем необходимые пакеты:

apt-get install pkg-config libglib2.0-dev libgmime-2.6-dev libmhash-dev libevent-dev libssl1.0-dev libzdb-dev
autoconf automake libtool autotools-dev dpkg-dev fakeroot

2. Скачиваем с dbmail.org исходники:

wget -c -t 0 -T 8 http://www.dbmail.org/download/3.1/dbmail-3.1.17.tar.gz

3. Распаковываем и компилируем:

cp dbmail-3.1.17.tar.gz /usr/local/src
tar -xf dbmail-3.1.17.tar.gz /usr/local/src.dbmail-3.1.17
cp dbmail-3.1.17.tar.gz /usr/local/src/dbmail_3.0.2.orig.tar.gz

Готовим пакет к сборке:

cd /usr/local/src/dbmail-3.2.3
./configure --with-pgsql --prefix=/usr
 
dpkg-source --commit

даем имя, что-то pgsql.commit

cd /usr/local/src/
dpkg-source -b dbmail-3.2.3
cd /usr/local/src/dbmail-3.2.3
dpkg-buildpackage -d
  • после того как соберется пакет, копируем себе в архив и ставим.
dpkg -i dbmail_3.2.3-1_amd64.deb
  • правим файл конфигурации:
editor /etc/dbmail/dbmail.conf
  • пример рабочего конфигурационного файла:
# (c) 2000-2006 IC&S, The Netherlands 
#
# Configuration file for DBMAIL 

[DBMAIL] 
# 
# Database settings
#
# database connection URI

#dburi                = sqlite:///var/tmp/dbmail.db

# 
# Supported drivers are sql, ldap.
#
authdriver           = sql

# 
# 
# following fields are now DEPRECATED!
driver               = postgresql
host                 = 10.0.5.2
sqlport              = 5432
#sqlsocket            =              
user                 = dbmail
pass                 = dbmailpass
db                   = mailbasename

#
# Number of database connections per threaded daemon
# This also determines the size of the worker threadpool
#
# Do NOT increase this without proper consideration. A
# very large database/worker pool will not only increase
# the connection pressure on the database, but will more
# significantly cause unnecessary context-switching in 
# your CPUs.
#
#max_db_connections   = 10

# 
# Table prefix. Defaults to "dbmail_" if not specified.
#
table_prefix         = dbmail_   

# 
# encoding must match the database/table encoding.
# i.e. latin1, utf8
encoding             = utf8

#
# messages with unknown encoding will be assumed to have 
# default_msg_encoding
# i.e. iso8859-1, utf8
default_msg_encoding = utf8

# 
# Postmaster's email address for use in bounce messages.
#
#postmaster           = DBMAIL-MAILER       

# 
# Sendmail executable for forwards, replies, notifies, vacations.
# You may use pipes (|) in this command, for example:
# dos2unix|/usr/sbin/sendmail  works well with Qmail.
# You may use quotes (") for executables with unusual names.
#
sendmail              = /usr/sbin/sendmail     

#
#
# The following items can be overridden in the service-specific sections.
#
#

#
# Logging via stderr/log file and syslog
#
# Logging is broken up into 8 logging levels and each level can be indivually turned on or off.
# The Stderr/log file logs all entries to stderr or the log file.
# Syslog logging uses the facility mail and the logging level of the event for logging.
# Syslog can then be configured to log data according to the levels.
#
# Set the log level to the sum of the values next to the levels you want to record.
#   1 = Emergency 
#   2 = Alert
#   4 = Critical
#   8 = Error
#  16 = Warning
#  32 = Notice
#  64 = Info
# 128 = Debug
# 256 = Database -> Logs at debug level
#
# Examples:   0 = Nothing
#            31 = Emergency + Alert + Critical + Error + Warning
#           511 = Everything
#
file_logging_levels       = 7
#
syslog_logging_levels     = 31

#
# Generate a log entry for database queries for the log level at number of seconds of query execution time.
#
query_time_info       = 10
query_time_notice     = 20
query_time_warning    = 30

#
# Throw an exception is the query takes longer than query_timeout seconds
query_timeout         = 300 

# 
# Root privs are used to open a port, then privs
# are dropped down to the user/group specified here.
#
effective_user        = dbmail
effective_group       = mail

# 
# The IPv4 and/or IPv6 addresses the services will bind to.
# Use * for all local interfaces.
# Use 127.0.0.1 for localhost only.
# Separate multiple entries with spaces ( ) or commas (,).
#
bindip                = 0.0.0.0         # IPv4 only - all IP's
#bindip                = ::             # IPv4 and IPv6 - all IP's (linux)
#bindip                = ::             # IPv6 only - all IP's (BSD)
#bindip                = 0.0.0.0,::     # IPv4 and IPv6 - all IP's (BSD)


#
# The maximum length of the queue of pending connections. See
# listen(2) for more information
#
# backlog              = 128

# 
# Idle time allowed before a connection is shut off.
#
timeout               = 300             

# 
# Idle time allowed before a connection is shut off if you have not logged in yet.
#
login_timeout         = 60

# 
# If yes, resolves IP addresses to DNS names when logging.
#
resolve_ip            = yes

#
# If yes, keep statistics in the authlog table for connecting users
#
authlog               = no

# 
# logfile for stdout messages
#
logfile               = /var/log/dbmail.log        

# 
# logfile for stderr messages
#
errorlog              = /var/log/dbmail.err        

# 
# directory for storing PID files
#
pid_directory         = /var/run/dbmail

#
# directory for locating libraries (normally has a sane default compiled-in)
#
library_directory       = /usr/lib/dbmail

#
# SSL/TLS certificates
#
# A file containing a list of CAs in PEM format
tls_cafile            =

# A file containing a PEM format certificate
tls_cert              =

# A file containing a PEM format RSA or DSA key
tls_key               =

# A cipher list string in the format given in ciphers(1)
tls_ciphers           =


# hashing algorithm. You can select your favorite hash type
# for generating unique ids for message parts. 
#
# for valid values check mhash(3) but minus the MHASH_ prefix.
#  
# if you ever change this value run 'dbmail-util --rehash' to 
# update the hash for all mimeparts.
#
# examples: MD5, SHA1, SHA256, SHA512, TIGER, WHIRLPOOL
#
# hash_algorithm = SHA1


# header_cache tuning
#
# set header_cache_readonly to 'yes' to prevent new
# unknown header-names from being cached.
#
# header_cache_readonly = yes



[LMTP]
bindip = 127.0.0.1
port                  = 24                 
#tls_port              =


[POP]
port                  = 110
#tls_port              = 995

# You can set an alternate banner to display when connecting to the service
# banner = DBMAIL pop3 server ready to rock

# 
# If yes, allows SMTP access from the host IP connecting by POP3.
# This requires addition configuration of your MTA
#
pop_before_smtp       = no      

[HTTP]
port                  = 41380
#
# the httpd daemon provides full access to all users, mailboxes
# and messages. Be very careful with this one!
bindip                = 127.0.0.1
admin                 = admin:secret

[IMAP]
# You can set an alternate banner to display when connecting to the service
# banner = imap 4r1 server (dbmail 2.3.x)

# 
# Port to bind to.
#
port                  = 143                
##tls_port              = 993

# 
# IMAP prefers a longer timeout than other services.
#
timeout               = 4000            

# 
# If yes, allows SMTP access from the host IP connecting by IMAP.
# This requires addition configuration of your MTA
#
imap_before_smtp      = no

#
# during IDLE, how many seconds between checking the mailbox
# status (default: 30)
#
# idle_timeout          = 30

# during IDLE, how often should the server send an '* OK' still
# here message (default: 10)
#
# the time between such a message is idle_timeout * idle_interval
# seconds
#
# idle_interval         = 10

#
# If TLS is enabled, login before starttls is normally
# not allowed. Use login_disabled=no to change this
#
# login_disabled        = yes

#
# Provide a CAPABILITY to override the default
#
# capability            = IMAP4 IMAP4rev1 AUTH=LOGIN ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE

# max message size. You can specify the maximum message size
# accepted by the IMAP daemon during APPEND commands.
#
# Supported formats:
#  decimal: 1000000    
#  octal:   03777777
#  hex:     0xfffff
#
# max_message_size      =


[SIEVE]
# 
# Port to bind to.
#
port                  = 2000               
tls_port              =


[LDAP]
port                  = 389
version               = 3
hostname              = ldap
base_dn               = ou=People,dc=mydomain,dc=com

# 
# If your LDAP library supports ldap_initialize(), then you can use the
# alternative LDAP server DSN like following.
#
# URI                = ldap://127.0.0.1:389
# URI                = ldapi://%2fvar%2frun%2fopenldap%2fldapi/

# 
# Leave blank for anonymous bind.
# example: cn=admin,dc=mydomain,dc=com     
#
bind_dn               = 

# 
# Leave blank for anonymous bind.
#
bind_pw               = 
scope                 = SubTree

# AD users may want to set this to 'no' to disable
# ldap referrals if you are seeing 'Operations errors' 
# in your logs
#
referrals             = yes

user_objectclass      = top,account,dbmailUser
forw_objectclass      = top,account,dbmailForwardingAddress
cn_string             = uid
field_passwd          = userPassword
field_uid             = uid
field_nid             = uidNumber
min_nid               = 10000
max_nid               = 15000
field_cid             = gidNumber
min_cid               = 10000
max_cid               = 15000

# a comma-separated list of attributes to match when searching
# for users or forwards that match a delivery address. A match
# on any of them is a hit.
field_mail            = mail

# field that holds the mail-quota size for a user.
field_quota           = mailQuota

# field that holds the forwarding address. 
field_fwdtarget       = mailForwardingAddress

# override the query string used to search for users 
# or forwards with a delivery address.
# query_string          = (mail=%s)

[DELIVERY]
# 
# Run Sieve scripts as messages are delivered.
#
SIEVE                 = yes               

# 
# Use 'user+mailbox@domain' format to deliver to a mailbox.
#
SUBADDRESS            = yes          

# 
# Turn on/off the Sieve Vacation extension.
#
SIEVE_VACATION        = yes      

# 
# Turn on/off the Sieve Notify extension
#
SIEVE_NOTIFY          = yes

# 
# Turn on/off additional Sieve debugging.
#
SIEVE_DEBUG           = no          


# Use the auto_notify table to send email notifications.
#
AUTO_NOTIFY           = no
 
# 
# Use the auto_reply table to send away messages.
#
AUTO_REPLY            = no

# 
# Defaults to "NEW MAIL NOTIFICATION"
#
#AUTO_NOTIFY_SUBJECT        =    

# 
# Defaults to POSTMASTER from the DBMAIL section.
#
#AUTO_NOTIFY_SENDER        =   


# If you set this to 'yes' dbmail will check for duplicate
# messages in the relevant mailbox during delivery using 
# the Message-ID header
#
suppress_duplicates     = no

#
# Soft or hard bounce on over-quota delivery
#
quota_failure           = hard


# end of configuration file

  • перезапуск службы:
systemctl restart dbmail
  • проверка работы с базой:
dbmail-util -av
 
  • С установкой dbmail пока окончено, следующий этап установка postgesql и настройка для будущей работы.

4. Настройка PostgreSQL

5. После того как мы настроили базу данных postgresql, создаем пользователя dbmail и базу dbmail

  • Создаем пользователя для работы с почтовой базой
createuser -U postgres -P dbmail
  • Создаем базу
createdb -U postgres --owner dbmail dbmail
  • Вместе с dbmail идут заготовки базы, распаковываем и заливаем:
bunzip2 /usr/share/doc/dbmail-2.2.10/create_tables.pgsql.bz2
psql -U dbmail -d dbmail < /usr/share/doc/dbmail-2.2.10/create_tables.pgsql
  • В этом дампе нету таблицы для работы с виртуальными доменами, создадим ее:
 CREATE TYPE dtype AS ENUM ( 
 'LOCAL', 
 'VIRTUAL', 
 'RELAY' 
); 

ALTER TYPE public.dtype OWNER TO dbmail; 

SET default_with_oids = true; 

CREATE TABLE dbmail_domains ( 
 uid integer NOT NULL, 
 domain character varying(128) NOT NULL, 
 type dtype NOT NULL 
);

INSERT INTO dbmail_domains (uid, domain, type) VALUES (1, 'example.com', 'LOCAL');

База готова.



Источники: