Postfix installieren und einrichten

Diskutiere Postfix installieren und einrichten im Mailserver Forum im Bereich Server; Eine knappe Anleitung, wie man Postfix installiert und einrichtet: apt-get install postfix postfix-mysql postfix-doc (local only) apt-get...
developr

developr

Teammitglied
Dabei seit
11.11.2008
Beiträge
336
Eine knappe Anleitung, wie man Postfix installiert und einrichtet:

Code:
apt-get install postfix postfix-mysql postfix-doc (local only)
apt-get install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl
apt-get install postfix-tls libsasl2 libsasl2-modules libsasl2-modules-sql openssl
  
CREATE TABLE `domains` (
  `domain` varchar(50) NOT NULL,
  PRIMARY KEY  (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `forwardings` (
  `source` varchar(80) NOT NULL,
  `destination` text NOT NULL,
  PRIMARY KEY  (`source`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `users` (
  `email` varchar(80) NOT NULL,
  `passwd` varchar(20) NOT NULL,
  PRIMARY KEY  (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  
mcedit /etc/postfix/mysql_domains.cf
user = postfix
password =
dbname = postfix
table = domains
select_field = domain
where_field = domain
hosts = 127.0.0.1

mcedit /etc/postfix/mysql_forwardings.cf
user = postfix
password =
dbname = postfix
table = forwardings
select_field = destination
where_field = source
hosts = 127.0.0.1

mcedit /etc/postfix/mysql_mailboxes.cf
user = postfix
password =
dbname = postfix
table = users
select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
where_field = email
hosts = 127.0.0.1

mcedit /etc/postfix/mysql_email2email.cf
user = postfix
password =
dbname = postfix
table = users
select_field = email
where_field = email
hosts = 127.0.0.1

chgrp postfix /etc/postfix/mysql_*.cf
chmod u=rw,g=r,o= /etc/postfix/mysql_*.cf
groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /home/vmail -m

mcedit /etc/postfix/sasl/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login cram-md5 digest-md5
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: postfix
sql_passwd:
sql_database: postfix
sql_select: SELECT passwd FROM users WHERE email='%[email protected]%r'

chown root:postfix /etc/postfix/sasl/smtpd.conf
chmod u=rw,g=r,o= /etc/postfix/sasl/smtpd.conf
openssl req -new -outform PEM -out /etc/postfix/smtpd.cert -newkey rsa:2048 -nodes -keyout /etc/postfix/smtpd.key -keyform PEM -days 3650 -x509
chmod u=rw,g=r,o= /etc/postfix/smtpd.key
chown root:postfix /etc/postfix/smtpd.key
  
mcedit /etc/courier/authdaemonrc
authmodulelist="authmysql"

mcedit /etc/courier/authmysqlrc
MYSQL_SERVER 127.0.0.1
MYSQL_USERNAME postfix
MYSQL_PASSWORD
MYSQL_PORT 3306
MYSQL_DATABASE postfix
MYSQL_USER_TABLE users
#MYSQL_CRYPT_PWFIELD (comment this out)
MYSQL_CLEAR_PWFIELD passwd
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
#MYSQL_NAME_FIELD (comment this out)

mcedit /etc/postfix/main.cf
myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, 127.0.0.1, localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

virtual_alias_maps = mysql:/etc/postfix/mysql_forwardings.cf mysql:/etc/postfix/mysql_email2email.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailboxes.cf
virtual_mailbox_base = /srv/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

smtpd_sasl_auth_enable = yes
smtpd_sasl2_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain =
broken_sasl_auth_clients = yes
smtpd_etrn_restrictions = reject
disable_vrfy_command = yes
smtpd_helo_required = yes
strict_rfc821_envelopes = yes
invalid_hostname_reject_code = 554
multi_recipient_bounce_reject_code = 554
non_fqdn_reject_code = 554
relay_domains_reject_code = 554
unknown_address_reject_code = 554
unknown_client_reject_code = 554
unknown_hostname_reject_code = 554
unknown_local_recipient_reject_code = 554
unknown_relay_recipient_reject_code = 554
unknown_sender_reject_code = 554
unknown_virtual_alias_reject_code = 554
unknown_virtual_mailbox_reject_code = 554
unverified_recipient_reject_code = 554
unverified_sender_reject_code = 554

smtpd_recipient_restrictions =
            reject_invalid_hostname,
            reject_unknown_recipient_domain,
            reject_unauth_pipelining,
            permit_mynetworks,
            permit_sasl_authenticated,
            reject_unauth_destination,
            reject_rbl_client zen.spamhaus.org,
            reject_rbl_client dnsbl.sorbs.net,
            reject_rbl_client list.dsbl.org,
            reject_rbl_client ix.dnsbl.manitu.net,
            reject_rbl_client bl.spamcop.net,
            reject_rbl_client dsn.rfc-ignorant.org,
            reject_rbl_client dul.dnsbl.sorbs.net,
            reject_rbl_client combined.rbl.msrbl.net,
            reject_rbl_client rabl.nuclearelephant.com,
            reject_rbl_client relays.ordb.org,
            reject_rbl_client blackholes.easynet.nl,
            reject_rbl_client proxies.blackholes.wirehub.net,
            reject_rbl_client opm.blitzed.org,
            reject_rbl_client dnsbl.njabl.org,
            reject_rbl_client multihop.dsbl.org,
            permit

# smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
unknown_local_recipient_reject_code = 450
 
Thema:

Postfix installieren und einrichten

Oben