EmailServer: Unterschied zwischen den Versionen

Aus Info-Theke
Zur Navigation springen Zur Suche springen
Zeile 128: Zeile 128:
chmod o-rwx,g+r mysql_*
chmod o-rwx,g+r mysql_*
chgrp postfix mysql_*
chgrp postfix mysql_*
postmap transport
postmap virtual-domains
postmap virtual
postmap vmailbox
service postfix reload
</pre>
== Konfiguration dovecot ==
<pre>
cd /etc/dovecot/
FN=dovecot.conf
DATE=$(date "+%Y.%m.%d")
mv $FN $FN.$DATE
cat <<$FN >$FN
protocols = imap imaps pop3 pop3s
log_timestamp = "%Y-%m-%d %H:%M:%S "
ssl_cert_file = /etc/postfix/sslcert/mailserver.crt
ssl_key_file = /etc/postfix/sslcert/mailserver.key
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}
protocol lda {
  postmaster_address = aender.mich@example.org
  auth_socket_path = /var/run/dovecot/auth-master
}
auth default {
  mechanisms = plain login
  passdb sql {
    args = /etc/dovecot/dovecot-mysql.conf
  }
  userdb sql {
    # Path for SQL configuration file, see /etc/dovecot/dovecot-sql.conf for example
    args = /etc/dovecot/dovecot-mysql.conf
  }
  user = root
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0600
      user = vmail
    }
    client {
      path = /var/spool/postfix/private/auth_dovecot
      mode = 0660
      user = postfix
      group = postfix
    }
  }
}
EOS
</pre>
* dovecot-mysql.conf
<pre>
FN=dovecot-mysql.conf
test -f $FN || cat <<EOS >$FN
driver = mysql
connect = host=localhost dbname=postfixdb user=postfix password=mysqlpw
default_pass_scheme = PLAIN-MD5
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT CONCAT('maildir:/var/vmail/',maildir) AS mail, 150 AS uid, 150 AS gid FROM mailbox WHERE username = '%u'
EOS
chmod o-rwx,g+r $FN
chgrp vmail $FN
service dovecot reload
</pre>
</pre>

Version vom 5. April 2014, 00:53 Uhr

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_*

postmap transport
postmap virtual-domains
postmap virtual
postmap vmailbox
service postfix reload

Konfiguration dovecot

cd /etc/dovecot/
FN=dovecot.conf
DATE=$(date "+%Y.%m.%d")
mv $FN $FN.$DATE
cat <<$FN >$FN
protocols = imap imaps pop3 pop3s

log_timestamp = "%Y-%m-%d %H:%M:%S "

ssl_cert_file = /etc/postfix/sslcert/mailserver.crt
ssl_key_file = /etc/postfix/sslcert/mailserver.key

protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}

protocol lda {
  postmaster_address = aender.mich@example.org
  auth_socket_path = /var/run/dovecot/auth-master
}

auth default {
  mechanisms = plain login

  passdb sql {
    args = /etc/dovecot/dovecot-mysql.conf
  }

  userdb sql {
    # Path for SQL configuration file, see /etc/dovecot/dovecot-sql.conf for example
    args = /etc/dovecot/dovecot-mysql.conf
  }

  user = root

  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0600
      user = vmail
    }
    client {
      path = /var/spool/postfix/private/auth_dovecot
      mode = 0660
      user = postfix
      group = postfix
    }
  }
}
EOS
  • dovecot-mysql.conf
FN=dovecot-mysql.conf
test -f $FN || cat <<EOS >$FN
driver = mysql
connect = host=localhost dbname=postfixdb user=postfix password=mysqlpw
default_pass_scheme = PLAIN-MD5
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT CONCAT('maildir:/var/vmail/',maildir) AS mail, 150 AS uid, 150 AS gid FROM mailbox WHERE username = '%u'
EOS
chmod o-rwx,g+r $FN
chgrp vmail $FN

service dovecot reload