GNU/Linux >> LINUX-Kenntnisse >  >> Cent OS

Mailserver mit virtuellen Benutzern und Domains mit Postfix und Dovecot auf einem CentOS 6 VPS

Der folgende Artikel zeigt Ihnen, wie Sie einfaches POP3 installieren und ausführen /IMAP /SMTP Mailserver in Ihrem CentOS VPS mit virtuellen Benutzern und Domains mit Postfix und Taubenschlag

Was ist Postfix? Es ist ein Ersatz für das alte und ausgereifte Sendmail. Postfix versucht außerdem, sehr schnell, einfach zu verwalten und sicher zu sein.

Was ist Dovecot? Es ist ein Open-Source-IMAP- und POP3-Server für *NIX-ähnliche Systeme, der hauptsächlich im Hinblick auf Sicherheit geschrieben wurde.

VORBEDARF

Sie sollten überprüfen, ob Ihr Hostname/Domainname ein gültiger FQDN (vollständig qualifizierter Domainname) ist und einen gültigen MX-DNS-Eintrag hat.

## if ! type -path "dig" > /dev/null 2>&1; then yum install bind-utils -y; fi
## DOMAIN=mydomain.com
## NSHOSTS=( "$(dig @4.2.2.2 +short MX ${DOMAIN}|sort -n|cut -d' ' -f2)" )
## for NS in ${NSHOSTS[@]}; do printf "%-15s => %-s\n" "$(dig @4.2.2.2 +short A ${NS})" "${NS}"; done
## unset DOMAIN NSHOSTS

SYSTEM AKTUALISIEREN

## screen -U -S mailserver-screen
## yum update

SYSTEMBENUTZER EINRICHTEN

Erstellen Sie eine Gruppe, die für virtuelle Postfächer verwendet wird

## groupadd vmail -g 2222

Erstellen Sie einen Benutzer, der für virtuelle Postfächer verwendet wird

## useradd vmail -r -g 2222 -u 2222 -d /var/vmail -m -c "mail user"

POSTFIX INSTALLIEREN

## yum remove exim sendmail
## yum install postfix cronie

Postfix main.cf bearbeiten Konfigurationsdatei

## cp /etc/postfix/main.cf{,.orig}
## vim /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps

inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost

debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

relay_domains = *
virtual_alias_maps=hash:/etc/postfix/vmail_aliases
virtual_mailbox_domains=hash:/etc/postfix/vmail_domains
virtual_mailbox_maps=hash:/etc/postfix/vmail_mailbox

virtual_mailbox_base = /var/vmail
virtual_minimum_uid = 2222
virtual_transport = virtual
virtual_uid_maps = static:2222
virtual_gid_maps = static:2222

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_sasl_local_domain = $mydomain
broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

Erstellen Sie vmail_domains Konfigurationsdatei. Hier fügen Sie Ihre virtuellen Domains hinzu.

## vim /etc/postfix/vmail_domains
mydomain.com            OK
my-otherdomain.com      OK

Erstellen Sie vmail_mailbox Konfigurationsdatei. Hier definieren Sie Ihre Mailboxen.

## vim /etc/postfix/vmail_mailbox
[email protected]           mydomain.com/info/
[email protected]     my-otherdomain.com/info/

Erstellen Sie vmail_aliases Konfigurationsdatei. Hier definieren Sie Ihre virtuellen Aliase.

## vim /etc/postfix/vmail_aliases
[email protected]           [email protected]
[email protected]     [email protected]

Hash der Konfigurationsdateien

## postmap /etc/postfix/vmail_domains
## postmap /etc/postfix/vmail_mailbox
## postmap /etc/postfix/vmail_aliases
## touch /etc/postfix/aliases
## vim +/submission /etc/postfix/master.cf
submission inet n       -       n       -       -       smtpd

TAUBENSCHLAG INSTALLIEREN

## yum install dovecot

dovecot dovecot.conf bearbeiten Konfigurationsdatei

## cp /etc/dovecot/dovecot.conf{,.orig}
## vim /etc/dovecot/dovecot.conf
listen = *
ssl = no
protocols = imap lmtp
disable_plaintext_auth = no
auth_mechanisms = plain login
mail_access_groups = vmail
default_login_user = vmail
first_valid_uid = 2222
first_valid_gid = 2222
#mail_location = maildir:~/Maildir
mail_location = maildir:/var/vmail/%d/%n

passdb {
    driver = passwd-file
    args = scheme=SHA1 /etc/dovecot/passwd
}
userdb {
    driver = static
    args = uid=2222 gid=2222 home=/var/vmail/%d/%n allow_all_users=yes
}
service auth {
    unix_listener auth-client {
        group = postfix
        mode = 0660
        user = postfix
    }
    user = root
}
service imap-login {
  process_min_avail = 1
  user = vmail
}

Erstellen Sie die Konfigurationsdatei des virtuellen Benutzers passwd . Hier werden Benutzernamen und Passwort-Hashes gespeichert.

## touch /etc/dovecot/passwd
## doveadm pw -s sha1 | cut -d '}' -f2

## vim /etc/dovecot/passwd
[email protected]:DOzcsKI8HY0bg8LAuz0DPKwS3WA=
## chown root: /etc/dovecot/passwd
## chmod 600 /etc/dovecot/passwd

DIENSTE STARTEN

## chkconfig postfix on
## chkconfig dovecot on
## service postfix restart
## service dovecot restart

TESTEN SIE DIE EINRICHTUNG

Öffnen Sie Ihren bevorzugten E-Mail-Client und konfigurieren Sie ihn so, dass er den neu erstellten [email protected] verwendet Konto. Versuchen Sie, eine E-Mail zu senden/empfangen. Wenn Probleme auftreten, überprüfen Sie, ob etwas in /var/log/maillog protokolliert wurde

Sie können auch swaks verwenden um Ihren SMTP-Server zu testen, zum Beispiel:

swaks --to [email protected] --from [email protected]

mehr Informationen über swaks findest du unter man swaks

WEITERES KONTO HINZUFÜGEN

Postfach des Einrichtungskontos

## vim /etc/postfix/vmail_mailbox
...
[email protected]           mydomain.com/support/

Alias(e) des Einrichtungskontos

## vim /etc/postfix/vmail_aliases
...
[email protected]           [email protected]

postmap-Konfigurationsdateien und starten Sie Postfix neu

## postmap /etc/postfix/vmail_mailbox
## postmap /etc/postfix/vmail_aliases
## service postfix restart

Passwort-Hash generieren und Benutzername:Passwort-Hash zur Passwd-Datei hinzufügen.

## doveadm pw -s sha1 | cut -d '}' -f2
## vim /etc/dovecot/passwd
...
[email protected]:DOzcsKI8HY0bg8LAuz0DPKwS3WA=

Dies ist ein einfaches, aber dennoch sehr robustes Mailserver-Setup auf einem CentOS 6 VPS, das SMTP und IMAP ohne SSL, Webmail, Anti-Spam, Anti-Virus, Filterregeln, Opendkim usw. unterstützt Artikeln werden wir dem Setup zusätzliche Funktionen hinzufügen, um es noch leistungsfähiger zu machen, also bleiben Sie dran.

  • Teil 2 – Roundcube-Webmail-Schnittstelle installieren und einrichten
  • Teil 3 – SSL-verschlüsselte Verbindung in Postfix, Dovecot und Apache einrichten
  • Teil 4 – So installieren und integrieren Sie SpamAssassin mit Postfix auf einem CentOS 6 VPS
  • Teil 5 – Installation und Integration von OpenDKIM mit Postfix auf einem CentOS 6 VPS
  • Teil 6 – Einrichten der serverseitigen E-Mail-Filterung mit Dovecot Sieve und Roundcube auf einem CentOS 6 VPS

Wenn Sie einer unserer Linux-VPS-Hosting-Kunden sind, müssen Sie dies natürlich nicht tun. Fragen Sie einfach unsere Administratoren, lehnen Sie sich zurück und entspannen Sie sich. Unsere Administratoren werden dies umgehend für Sie einrichten.

PS. Wenn Ihnen dieser Beitrag gefallen hat, teilen Sie ihn bitte mit Ihren Freunden in den sozialen Netzwerken über die Schaltflächen auf der linken Seite oder hinterlassen Sie einfach unten eine Antwort. Danke.


Cent OS
  1. Virtuelle Benutzer und Domänen mit Postfix, Courier, MySQL und SquirrelMail (Ubuntu 14.04LTS)

  2. Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (Ubuntu 13.10)

  3. Virtuelle Benutzer und Domänen mit Sendmail

  4. So installieren und integrieren Sie SpamAssassin mit Postfix auf einem CentOS 6 VPS

  5. Richten Sie einen Mailserver mit Exim und Dovecot auf einem CentOS 7 ein

Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (Ubuntu 10.04)

Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (Ubuntu 12.04 LTS)

Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (Ubuntu 12.10)

Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (Debian Wheezy)

Virtuelle Benutzer und Domains mit Postfix, Courier, MySQL und SquirrelMail (CentOS 6.3 x86_64)

Virtuelle Benutzer und Domänen mit Postfix, Courier, MySQL und SquirrelMail (Fedora 18 x86_64)