Annak érdekében, hogy hozzáférjünk postafiókunkban található leveleinkhez, szükségünk lesz a Dovecot szolgáltatásra is. A jelenlegi példánkban nem csak a felhasználóknak, hanem a Postfix szervernek is szüksége van a Dovecotra, mivel a bejövő leveleket nem közvetlenül a Postfix dobja be a postaládánkba, hanem átadja azt kézbesítésre a Dovecot szervernek. Így a Dovecot naprakész lesz a felhasználók kvóta adataival, el tudja végezni a szerver oldali levélszűrést és a vakációs üzenetek kezelését is. Sőt, a Postfixen keresztül levelet küldeni szándékozó felhasználókat is a Dovecot hitelesíti a megadott felhasználói név és jelszó alapján a Postfix szerver számára.
aptitude install dovecot-mysql dovecot-imapd dovecot-pop3d
Az /etc/postfix/master.cf fájl alábbi kiegészítése mondja meg a Postfixnek, hogyan adja át a levelet a Dovecotnak kézbesítésre:
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
A /etc/dovecot/conf.d/10-master.conf fájl tartalma:
default_vsz_limit = 256M
service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
service_count = 1
process_min_avail = 0
}
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
service lmtp {
unix_listener lmtp {
mode = 0666
}
}
service imap {
process_limit = 1024
}
service pop3 {
process_limit = 1024
}
service auth {
unix_listener auth-userdb {
mode = 0660
user = vmail
group = vmail
}
# Postfix SMTP-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
user =
group =
}
service auth-worker {
user = $default_internal_user
}
service dict {
unix_listener dict {
mode = 0660
user = vmail
group = vmail
}
}
A /etc/dovecot/conf.d/10-auth.conf tartalma:
disable_plaintext_auth = yes auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@ auth_username_format = %Lu auth_worker_max_count = 30 auth_failure_delay = 2 secs auth_ssl_require_client_cert = no auth_mechanisms = plain login !include auth-sql.conf.ext
A Dovecotnak is szüksége van tanúsítványra a titkosított IMAP és POP3 kapcsolatok felépítéséhez:
mkdir /etc/dovecot/certs openssl req -new -x509 -days 365 -nodes -out /etc/dovecot/certs/dovecot.pem -keyout /etc/dovecot/private/dovecot.key
A válaszok ismét:
Country Name: HU State or Province Name: Pest Locality Name: Budapest Organization Name: Comega7 Organizational Unit Name: IT Common Name: mailserver.comega7.local Email Address: bolemanyi.attila@comega7.local
A Common Name itt is a levelezőszerver neve kell, hogy legyen. A felhasználóknak ezt a nevet kell megadni POP3 és IMAP szerver névnek, amikor a levelezőprogramjaik beállításával foglalatoskodnak.
A /etc/dovecot/conf.d/10-ssl.conf fájl tartalma:
ssl = yes ssl_cert = </etc/dovecot/certs/dovecot.pem ssl_key = </etc/dovecot/private/dovecot.key ssl_protocols = !SSLv2 ssl_cipher_list = ALL:!LOW:!SSLv2:!EXP:!aNULL
A /etc/dovecot/conf.d/10-mail.conf fájl tartalma:
mail_location = maildir:/srv/mail/vmail/%d/%n
mail_home = /srv/mail/sieve/%d/%n
namespace inbox {
type = private
separator =
prefix =
location =
inbox = yes
hidden = no
list = yes
subscriptions = yes
}
mail_shared_explicit_inbox = no
mail_uid = vmail
mail_gid = vmail
mail_full_filesystem_access = no
first_valid_uid = 5000
last_valid_uid = 5000
first_valid_gid = 5000
last_valid_gid = 5000
auth_socket_path = /var/run/dovecot/auth-userdb
mail_plugin_dir = /usr/lib/dovecot/modules
mail_plugins = $mail_plugins quota
A /etc/dovecot/conf.d/15-mailboxes.conf fájl tartalma:
namespace inbox {
mailbox Drafts {
special_use = \Drafts
auto = subscribe
}
mailbox Junk {
special_use = \Junk
auto = subscribe
}
mailbox Trash {
special_use = \Trash
auto = subscribe
}
mailbox Sent {
special_use = \Sent
auto = subscribe
}
mailbox "Sent Messages" {
special_use = \Sent
auto = no
}
}
A /etc/dovecot/conf.d/auth-sql.conf.ext fájl tartalma:
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
A /etc/dovecot/conf.d/20-imap.conf fájl tartalma:
imap_max_line_length = 64k
imap_logout_format = in=%i out=%o
imap_capability =
imap_idle_notify_interval = 2 mins
imap_id_send =
imap_id_log =
imap_client_workarounds = delay-newmail tb-extra-mailbox-sep tb-lsub-flags
imap_urlauth_host =
protocol imap {
mail_plugins = $mail_plugins imap_quota
mail_max_userip_connections = 10
}
A /etc/dovecot/conf.d/20-pop3.conf fájl tartalma:
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
protocol pop3 {
mail_plugins = $mail_plugins quota
}
A /etc/dovecot/dovecot-dict-sql.conf.ext fájl tartalma:
connect = host=localhost dbname=postfix user=postfix password=Pa$$w0rd
map {
pattern = priv/quota/storage
table = quota2
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota2
username_field = username
value_field = messages
}
A /etc/dovecot/conf.d/90-quota.conf fájl tartalma:
plugin {
quota = dict:user::proxy::quota_dict
}
A /etc/dovecot/dovecot.conf fájl tartalma:
!include_try /usr/share/dovecot/protocols.d/*.protocol
base_dir = /var/run/dovecot/
instance_name = dovecot
login_greeting = Dovecot ready.
shutdown_clients = yes
dict {
quota_dict = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
!include conf.d/*.conf
!include_try local.conf
A /etc/dovecot/conf.d/15-lda.conf fájl tartalma:
protocol lda {
mail_plugins = $mail_plugins quota
}
A /etc/dovecot/dovecot-sql.conf.ext fájl tartalma:
driver = mysql
connect = dbname=postfix user=postfix host=127.0.0.1 password=Pa$$w0rd
default_pass_scheme = MD5-CRYPT
password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active ='1'
user_query = SELECT maildir, 5000 AS uid, 5000 AS gid, CONCAT('*:bytes=', CAST(quota AS CHAR)) AS quota_rule FROM mailbox WHERE username = '%u' AND active ='1'
Indítsuk újra a Dovecot és a Postfix szervereket:
service dovecot restart service postfix restart