EmailServer

Aus Info-Theke
Zur Navigation springen Zur Suche springen

Installation

apt-get install dovecot-common dovecot-imapd dovecot-pop3d postfix postfix-mysql openssl
PUSR=postfix
mysqladmin -u $PUSR -p create postfixdb

groupadd -g 150 vmail
useradd -g vmail -u 150 vmail -d /var/vmail
mkdir /var/vmail
chown vmail:vmail /var/vmail

test -d /etc/postfix/sslcert || mkdir /etc/postfix/sslcert
cd /etc/postfix/sslcert

# DN muss ausgefüllt werden, z.B. mail.i-sar.eu
openssl req -new -newkey rsa:3072 -nodes -keyout mailserver.key -days 730 -x509 -out mailserver.crt

chmod go-rwx mailserver.key

Konfiguration postfix

  • /etc/postfix/main.cf:
# check for replacement:
smtpd_tls_cert_file = /etc/postfix/sslcert/mailserver.crt
smtpd_tls_key_file = /etc/postfix/sslcert/mailserver.key

# The rest is new:
# a bit more spam protection
disable_vrfy_command = yes


# Authentification
smtpd_sasl_type=dovecot
smtpd_sasl_path=private/auth_dovecot
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
broken_sasl_auth_clients = yes

proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps

smtpd_sender_login_maps = proxy:mysql:/etc/postfix/mysql_sender_login_maps.cf

smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch
        reject_unknown_sender_domain

smtpd_recipient_restrictions = permit_sasl_authenticated
        permit_mynetworks
        reject_unauth_destination


# Virtual mailboxes
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_base = /var/vmail/
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 112400000
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 104
virtual_transport = virtual
virtual_uid_maps = static:150
virtual_gid_maps = static:150
virtual_transport = dovecot

dovecot_destination_recipient_limit = 1

local_transport = virtual
  • /etc/postfix/master.cf
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}

smtps     inet  n       -       -       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  • /etc/postfix/mysql_virtual_alias_maps.cf
FN=/etc/postfix/mysql_virtual_alias_maps.cf
PW=geheim
test -f $FN || cat <<EOS >$FN
hosts = localhost
user = $PUSR
password = $PW
dbname = postfixdb
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
EOS
  • /etc/postfix/mysql_virtual_mailbox_maps.cf
FN=/etc/postfix/mysql_virtual_mailbox_maps.cf
test -f $FN || cat <<EOS >$FN
hosts = localhost
user = $PUSR
password = $PW
dbname = postfixdb
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
EOS
  • /etc/postfix/mysql_sender_login_maps.cf
FN=/etc/postfix/mysql_sender_login_maps.cf
test -f $FN || cat <<EOS >$FN
hosts = localhost
user = $PUSR
password = $PW
dbname = postfixdb
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
EOS
  • /etc/postfix/mysql_virtual_domains_maps.cf
FN=/etc/postfix/mysql_sender_login_maps.cf
test -f $FN || cat <<EOS >$FN
hosts = localhost
user = $PUSR
password = $PW
dbname = postfixdb
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
EOS
chmod o-rwx,g+r mysql_*
chgrp postfix mysql_*