[howto] Debian 7.0 “Wheezy”: mail server con Postfix, Dovecot e mySql (parte 3)
Installazione di Horde
Horde non è presente nei canali ufficiali della distribuzione stabile. E’ possibile installarlo utilizzando le liste “Jessie” (Testing). Per farlo, creare un file di configurazione per apt:
nano -w /etc/apt/sources.list.d/jessie.list
con questo contenuto:
deb http://ftp.fr.debian.org/debian jessie main
Successivamente, creare un file di preferenze per il pacchetto hode:
nano -w /etc/apt/preferences.d/horde.pref
con questo contenuto:
Package: *
Pin: release a=testing
Pin-Priority: 100
Package: php-horde php-horde-*
Pin: release a=testing
Pin-Priority: 500
EOF
Infine, aggiornare apt con il comando
apt-get update
e installare Horde
apt-get install php-horde-groupware
groupware-install
Installare i moduli IMP, INGO e PASSWD
IMP permette di aggiungere la funzionalità di webmail ad Horde; INGO la gestione delle regole per il filtro dei messaggi, whitelist, blacklist e vacation; PASSWD la possibilità di cambio password direttamente dall’interfaccia web.
Installazione dei moduli:
apt-get install php-horde-imp php-horde-passwd php-horde-ingo
Configurazione di IMP
Dall’interfaccia web di Horde, abilitare il modulo, aggiornare lo schema db e infine generare un file di configurazione. Quindi, da shell, creare un file di configurazione per il backend che consentirà ad IMP di collegarsi al server di posta per la lettura delle mail:
nano -w /usr/share/horde/imp/config/backends.local.php
inserendo il contenuto seguente
false,
'name' => 'Locale',
'hostspec' => 'localhost',
'hordeauth' => true,
'protocol' => 'imap',
'port' => 143,
'secure' => false,
'acl' => false,
'cache' => false,
'debug' => '/tmp/imp_imap.log',
'debug_raw' => false,
'autocreate_special' => false,
'preferred' => 'true',
'folders' => true,
);
Per abilitare di default la visualizzazione delle mail in HTML, creare il file mime_drivers.local.php nella cartella config di imp:
nano -w /usr/share/horde/imp/config/mime_drivers.local.php
con questo contenuto:
Infine, è possibile impostare Horde per l'autenticazione su IMP (in modo da non rendere necessario l'inserimento degli utenti anche nel db di Horde):
nano -w /usr/share/horde/config/conf.php
editare le righe:
$conf['auth']['params']['driverconfig'] = 'imp';
$conf['auth']['params']['app'] = 'imp';
$conf['auth']['driver'] = 'application';
Configurazione di PASSWD
Dall'interfaccia web di Horde, abilitare il modulo, aggiornare lo schema db e infine generare un file di configurazione. Quindi, da shell, creare un file di configurazione per il backend che consentirà a PASSWD di collegarsi a mySql per modificare la password degli utenti:
nano -w /usr/share/horde/passwd/config/backends.local.php
Inserendo il seguente testo:
false,
'name' => 'mySql Server',
'driver' => 'Sql',
'policy' => array(
'minLength' => 8,
'minNumeric' => 1,
'maxSpace' => 0,
'maxLength' => 16,
'minUpper' => 1,
'minLower' => 1,
'minSymbols’ => 0
),
'params' => array(
'phptype' => 'mysql',
'hostspec' => '127.0.0.1',
'username' => 'mailuser',
'password' => 'mailpassword',
'encryption' => 'crypt-sha512',
'database' => 'mail',
'table' => 'virtual_users',
'user_col' => 'email',
'pass_col' => 'password',
'show_encryption' => false
),
);
Nella sezione policy, è possibile indicare il grado di complessità da richiedere nella modifica della password (come da ordine indicato, lunghezza minima - minimo numero di caratteri numerici - massimo numero di spazi - lunghezza massima - minimo numero di caratteri maiuscoli - minimo numero di caratteri minuscoli - minimo numero di simboli speciali). Nella sezione params vanno indicati i parametri per la connessione al server mysql e il tipo di crittografia utilizzata per la password (la stessa indicata nella parte 1 nella configurazione di dovecot)
Configurazione di INGO
Dall'interfaccia web di Horde, abilitare il modulo, aggiornare lo schema db e infine generare un file di configurazione. Quindi, da shell, creare un file di configurazione per il backend che consentirà a INGO di generare correttamente il file con le regole per sieve (modulo di dovecot per il filtro della posta, alternativa a procmail):
nano -w /usr/share/horde/ingo/config/backends.local.php
$backends['sieve'] = array(
'disabled' => false,
'preferred' => true,
'transport' => array(
Ingo::RULE_ALL => array(
'driver' => 'vfs',
'params' => array(
'filename' => '.dovecot.sieve',
'vfstype' => 'file',
'vfsroot' => '/var/mail/vhosts',
'vfs_path' => '/%d/%U',
'file_perms' => '666'
),
),
),
'script' => array(
Ingo::RULE_ALL => array(
'driver' => 'sieve',
'params' => array(
'utf8' => true,
),
),
),
'shares' => false
);
Infine, per la distribuzione Debian, è necessario modificare/creare il file config/hooks.php:
nano -w /usr/share/horde/ingo/config/hooks.php
con questo contenuto:
call('mail/imapOb');
return array(
'password' => $ob->getParam('password'),
'username' => $ob->getParam('username')
);
}
return true;
}
}
Installazione e configurazione di SIEVE
Installare il pacchetto dovecot-sieve con il comando:
apt-get install dovecot-sieve
Quindi, abilitare il protocollo nel file dovecot.conf
nano -w /etc/dovecot/dovecot.conf
alle righe
# Enable installed protocols
!include_try /usr/share/dovecot/protocols.d/*.protocol
protocols = imap pop3 lmtp sieve
Assicurarsi che il plugin non sia attivato nel file 10-mail.conf
nano -w /etc/dovecot/conf.d/10-mail.conf
eventuamente commentandolo
mail_plugins = #sieve
Abilitare il plugin nel file 15-lda.conf
nano -w /etc/dovecot/conf.d/15-lda.conf
protocol lda {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
mail_debug=yes
}
Abilitare il plugin nel file 20-lmtp.conf
nano -w /etc/dovecot/conf.d/20-lmtp.conf
protocol lmtp {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
mail_debug=yes
}
Infine, creare/modificare il file 90-sieve.conf, abilitando le estensioni notify e imapflags (riga sieve_extensions = +notify +imapflags)
nano -w /etc/dovecot/conf.d/90-sieve.conf
##
## Settings for the Sieve interpreter
##
# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf
# by adding it to the respective mail_plugins= settings.
plugin {
# The path to the user's main active script. If ManageSieve is used, this the
# location of the symbolic link controlled by ManageSieve.
sieve = ~/.dovecot.sieve
# The default Sieve script when the user has none. This is a path to a global
# sieve script file, which gets executed ONLY if user's private Sieve script
# doesn't exist. Be sure to pre-compile this script manually using the sievec
# command line tool.
# --> See sieve_before fore executing scripts before the user's personal
# script.
#sieve_default = /var/lib/dovecot/sieve/default.sieve
# Directory for :personal include scripts for the include extension. This
# is also where the ManageSieve service stores the user's scripts.
sieve_dir = ~/sieve
# Directory for :global include scripts for the include extension.
#sieve_global_dir =
# Path to a script file or a directory containing script files that need to be
# executed before the user's script. If the path points to a directory, all
# the Sieve scripts contained therein (with the proper .sieve extension) are
# executed. The order of execution within a directory is determined by the
# file names, using a normal 8bit per-character comparison. Multiple script
# file or directory paths can be specified by appending an increasing number.
#sieve_before =
#sieve_before2 =
#sieve_before3 = (etc...)
# Identical to sieve_before, only the specified scripts are executed after the
# user's script (only when keep is still in effect!). Multiple script file or
# directory paths can be specified by appending an increasing number.
#sieve_after =
#sieve_after2 =
#sieve_after2 = (etc...)
# Which Sieve language extensions are available to users. By default, all
# supported extensions are available, except for deprecated extensions or
# those that are still under development. Some system administrators may want
# to disable certain Sieve extensions or enable those that are not available
# by default. This setting can use '+' and '-' to specify differences relative
# to the default. For example `sieve_extensions = +imapflags' will enable the
# deprecated imapflags extension in addition to all extensions were alr$
# enabled by default.
sieve_extensions = +notify +imapflags
# Which Sieve language extensions are ONLY available in global scripts. This
# can be used to restrict the use of certain Sieve extensions to administrator
# control, for instance when these extensions can cause security concerns.
# This setting has higher precedence than the `sieve_extensions' setting
# (above), meaning that the extensions enabled with this setting are never
# available to the user's personal script no matter what is specified for the
# `sieve_extensions' setting. The syntax of this setting is similar to the
# `sieve_extensions' setting, with the difference that extensions are
# enabled or disabled for exclusive use in global scripts. Currently, no
# extensions are marked as such by default.
#sieve_global_extensions =
# The Pigeonhole Sieve interpreter can have plugins of its own. Using this
# setting, the used plugins can be specified. Check the Dovecot wiki
# (wiki2.dovecot.org) or the pigeonhole website
# (http://pigeonhole.dovecot.org) for available plugins.
#sieve_plugins =
# The separator that is expected between the :user and :detail
# address parts introduced by the subaddress extension. This may
# also be a sequence of characters (e.g. '--'). The current
# implementation looks for the separator from the left of the
# localpart and uses the first one encountered. The :user part is
# left of the separator and the :detail part is right. This setting
# is also used by Dovecot's LMTP service.
#recipient_delimiter = +
# The maximum size of a Sieve script. The compiler will refuse to compile any
# script larger than this limit. If set to 0, no limit on the script size is
# enforced.
#sieve_max_script_size = 1M
# The maximum number of actions that can be performed during a single script
# execution. If set to 0, no limit on the total number of actions is enforced.
#sieve_max_actions = 32
# The maximum number of redirect actions that can be performed during a single
# script execution. If set to 0, no redirect actions are allowed.
#sieve_max_redirects = 4
# The maximum number of personal Sieve scripts a single user can have. If set
# to 0, no limit on the number of scripts is enforced.
# (Currently only relevant for ManageSieve)
#sieve_quota_max_scripts = 0
# The maximum amount of disk storage a single user's scripts may occupy. If
# set to 0, no limit on the used amount of disk storage is enforced.
# (Currently only relevant for ManageSieve)
#sieve_quota_max_storage = 0
}
Riavviare il servizio dovecot
service dovecot restart
e aggiungere l'utente www-data al gruppo vmail
gpasswd -a www-data vmail
per consentire a INGO di scrivere il file di configurazione di sieve nella home dell'utente
Abilitare il protocollo ActiveSync
Installare il pacchetto horde-activesync
apt-get install php-horde-activesync
Quindi, abilitarlo in horde dal menù di configurazione (eventualmente aggiornare lo schema se richiesto da Horde).
Modificare il file conf.local.php di Horde per attivare il modulo:
nano -w /usr/share/horde/config/conf.local.php
aggiungendo queste righe:
$conf['activesync']['enabled'] = true;
$conf['activesync']['version'] = '14.1';
$conf['activesync']['outlookdiscovery'] = true;
$conf['activesync']['logging']['path'] = '/tmp';
$conf['activesync']['logging']['type'] = 'custom';
$conf['activesync']['emailsync'] = true;
$conf['activesync']['ping']['forcedheartbeat'] = 60;
$conf['activesync']['ping']['deviceping'] = false;
$conf['activesync']['ping']['waitinterval'] = 15;
$conf['activesync']['emailsync'] = true;
//$conf['activesync']['autodiscovery'] = 'full';
//$conf['activesync']['hosts']['imap']['host'] = 'mail.domain.com';
//$conf['activesync']['hosts']['imap']['port'] = 143;
//$conf['activesync']['hosts']['imap']['ssl'] = false;
//$conf['activesync']['hosts']['pop']['host'] = 'mail.domain.com';
//$conf['activesync']['hosts']['pop']['port'] = 110;
//$conf['activesync']['hosts']['pop']['ssl'] = false;
//$conf['activesync']['hosts']['smtp']['host'] = 'mail.domain.com';
//$conf['activesync']['hosts']['smtp']['port'] = 25;
//$conf['activesync']['hosts']['smtp']['popauth'] = true;
//$conf['activesync']['hosts']['smtp']['ssl'] = false;
Infine, modificare il file di configurazione di apache relativo al sito horde creando gli alias necessari
nano -w /etc/apache2/sites-available/mail.esempio.it
come da esempio seguente:
ServerAdmin info@esempio.it
ServerName mail.esempio.it
ServerAlias mail.esempio.it
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /usr/share/horde/
AllowOverride All
Alias /Microsoft-Server-ActiveSync /usr/share/horde/rpc.php
# Logfiles
ErrorLog /var/log/apache2/error.esempio.it.log
CustomLog /var/log/apache2/access.esempio.it.log combined
ServerAdmin info@esempio.it
ServerName mail.esempio.it
ServerAlias mail.esempio.it
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /usr/share/horde/
AllowOverride None
Alias /Microsoft-Server-ActiveSync /usr/share/horde/rpc.php
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Per ulteriori informazioni, fare riferimento alla wiki di Horde (http://wiki.horde.org/ActiveSync). E' possibile trovare un esempio relativo all'attivazione del servizio autodiscover.