Nastavení mail serveru: Porovnání verzí

Z ZděchovNET
Skočit na navigaci Skočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 8: Řádek 8:




=Instalační skript=
* Nainstalujte potřebné balíčky


<pre>
<pre>yum install postfix dovecot php-imap dovecot-mysql system-switch-mail roundcubemail</pre>


* Přidejte systémový účet pro virtuální schránky

<pre># useradd vmail</pre>


* Doplňte do souboru '''/etc/postfix/main.cf''' nastavení pro schránky:

<pre>virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:505
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 505
virtual_transport = virtual
virtual_uid_maps = static:505
</pre>
</pre>


Obsažené číslo UID upravte dle systémového UID uživatele vmail.


* Pokud váš server musí předávat poštu přes zadaný SMTP server, doplňte také řádek pro nastavení SMTP předávacího serveru
<pre>relayhost = smtp.zdechov.net</pre>


* Dále vytvořte ve složce '''/etc/postfix''' soubory se zadaným obsahem a upravte přihlašovací pro váš MySQL server:

'''Soubor mysql_relay_domains_maps.cf'''
<pre>user = postfix
password = heslo
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and backupmx = '1'</pre>

'''Soubor mysql_virtual_alias_maps.cf'''
<pre>user = postfix
password = heslo
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address</pre>

'''Soubor mysql_virtual_domains_maps.cf'''
<pre>user = postfix
password = heslo
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'</pre>

'''Soubor mysql_virtual_mailbox_limit_maps.cf'''
<pre>user = postfix
password = heslo
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'</pre>

'''Soubor mysql_virtual_mailbox_maps.cf'''
<pre>user = postfix
password = heslo
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'</pre>


* Konfigurační soubor '''/etc/dovecot.conf''' nastavte např. takto:
<pre>dovecot.conf 882/1668 UTF-8 52%
auth_debug_passwords = yes

# Log file to use for error messages, instead of sending them to syslog.
# /dev/stderr can be used to log into stderr.
log_path = /var/log/dovecot.log

# Log file to use for informational and debug messages.
# Default is the same as log_path.
info_log_path = /var/log/dovecot-info.log


# More verbose logging. Useful for figuring out why authentication isn't
# working.
auth_verbose = yes

# Even more verbose logging for debugging purposes. Shows for example SQL
# queries.
auth_debug = yes


mail_location = maildir:~/Maildir

#mail_location = maildir:/home/vmail/%d/%u
first_valid_uid = 505
last_valid_uid = 505
maildir_copy_with_hardlinks = yes

protocol imap {
mail_plugins = quota imap_quota
imap_client_workarounds = outlook-idle delay-newmail
}

protocol pop3 {
mail_plugins = quota
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}

protocol lda {
postmaster_address = postmaster@domena.cz
mail_plugins = quota
log_path = /var/log/dovecot-deliver.log
info_log_path = /var/log/dovecot-deliver.log
}

auth default {
# Having "login" also as a mechanism make sure outlook can use the auth smtpd as well
# http://wiki.dovecot.org/Authentication/Mechanisms
mechanisms = plain login
passdb sql {
args = /etc/dovecot/sql.conf
}
userdb sql {
args = /etc/dovecot/sql.conf
}
userdb prefetch {
}
user = nobody
socket listen {
master {
path = /var/run/dovecot/auth-master
mode = 0660
user = vmail
group = mail
}
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = mail
}
}
}

dict {
}</pre>


* Pak nastavení Dovecotu pro přípojení k MySQL serveru je potřeba vytvořit v souboru '''/etc/dovecot/sql.conf''' takto:
<pre>driver = mysql
connect = host=localhost dbname=postfix user=postfix password=heslo
user_query = SELECT concat('/home/vmail/', maildir) as home, concat('maildir:/home/vmail/', maildir) as mail, 505 AS uid, 12
AS gid, concat('maildir:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
# fast but now so nice:-)
#user_query = SELECT '/var/vmail/%d/%n' as home, 'maildir:/var/vmail/%d/%n' as mail, 101 AS uid, 12 AS gid, concat('dirsize:
storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
# Just in case you are using postfix the delimiter char "+", the above query will probably fail for the username '%n' or '%u
' and result in a "5.5.1 user unknown" error
#in this case, you will probalby want to use a separate user and domain part, whilst searching only for the destination user
part (user_query only):
# SELECT ... WHERE username = substring_index('%n','+',1) AND userrealm = '%d'

password_query = SELECT username as user, password, concat('/home/vmail/', maildir) as userdb_home, concat('maildir:/home/vm
ail/', maildir) as userdb_mail, 505 as userdb_uid, 12 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'
# fast but now so nice:-)
#password_query = SELECT username as user, password, '/var/vmail/%d/%n' as userdb_home, 'maildir:/var/vmail/%d/%n' as userdb
_mail, 101 as userdb_uid, 12 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'</pre>


* Nastavit automatické spouštění potřebných služeb

<pre>chkconfig dovecot on
chkconfig postfix on</pre>


* Stáhněte a nainstalujte [http://sourceforge.net/projects/postfixadmin/files/ Postfix Admin] např. do složky '''/var/www/html/postfixadmin/'''


* Prohlédněte a nastavte obsah souboru '''config.inc.php''' jako:
<pre>$CONF['configured'] = true;
$CONF['default_language'] = 'cs';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'heslo';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';
$CONF['encrypt'] = 'md5';
</pre>




=Vnější odkazy=
=Vnější odkazy=


* [https://www.exratione.com/2014/05/a-mailserver-on-ubuntu-1404-postfix-dovecot-mysql/ A Mailserver on Ubuntu 14.04: Postfix, Dovecot, MySQL]
* [http://www.howtoforge.com/virtual-users-and-domains-postfix-dovecot-mysql-centos4.5 How To Configure ISP Mail Server With Virtual Users/Domain On Centos 4.5 Using Postfix, Dovecot, MySQL, phpMyAdmin, TLS/SSL]
* [http://www.howtoforge.com/virtual-users-and-domains-postfix-dovecot-mysql-centos4.5 How To Configure ISP Mail Server With Virtual Users/Domain On Centos 4.5 Using Postfix, Dovecot, MySQL, phpMyAdmin, TLS/SSL]



Verze z 9. 11. 2014, 12:46

Návod popisuje instalace poštovního serveru s virtuálními účty v MySQL databázi.

  • Budou použity následují komponenty:
    • postfix - SMTP server
    • dovecot - IMAP server
    • roundcubemail - web mail klient
    • postfixadmin - správa schránek


Instalační skript



Vnější odkazy