Gestione domini virtual con postfixadmin: Difference between revisions
Jump to navigation
Jump to search
| (32 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Il pacchetto .deb di postfixadmin è stato inserito nel repository RVM. Alternativamente scaricarlo ed installarlo a mano | Il pacchetto .deb di postfixadmin è stato inserito nel repository RVM. Alternativamente scaricarlo ed installarlo a mano | ||
= | =Installazione= | ||
==Debian >= Jessie== | |||
* Il pacchetto è standard Debian: | |||
sudo apt-get install postfixadmin | |||
==Debian < Jessie== | |||
* Scaricare il .deb da sourceforge [http://sourceforge.net/projects/postfixadmin/files/postfixadmin/ Postfix Admin - Browse /postfixadmin at SourceForge.net] | * Scaricare il .deb da sourceforge [http://sourceforge.net/projects/postfixadmin/files/postfixadmin/ Postfix Admin - Browse /postfixadmin at SourceForge.net] | ||
* | * Attualmente l'ultima versione stabile è postfixadmin_2.3.7-1_all.deb | ||
sudo dpkg -i install postfixadmin_2.3.7-1_all.deb | |||
* | |||
* Installare le dipendenze necessarie: | |||
sudo apt-get install -f | |||
=Configurazione del Database= | |||
==Configurazione con db-config-common== | ==Configurazione con db-config-common== | ||
* Con questa modalità di configurazione, la parte database viene già | * Con questa modalità di configurazione, la parte database viene già configurata. | ||
==Configurazione database manuale== | ==Configurazione database manuale== | ||
| Line 41: | Line 48: | ||
<pre> | <pre> | ||
$CONF['postfix_admin_url'] = 'http://myserver.priv/postfixadmin'; | <?php | ||
$CONF['postfix_admin_url'] = 'http://myserver.example.priv/postfixadmin'; | |||
// URL per far funzionare i link interni | // URL per far funzionare i link interni | ||
| Line 47: | Line 55: | ||
// Lingua di default dell'interfaccia web | // Lingua di default dell'interfaccia web | ||
$CONF['admin_email'] = 'admin@ | $CONF['admin_email'] = 'admin@example.com'; | ||
// Il login inziale dell'utente amministrativo | // Il login inziale dell'utente amministrativo | ||
| Line 55: | Line 63: | ||
$CONF['default_aliases'] = array ( | $CONF['default_aliases'] = array ( | ||
'abuse' => 'abuse@ | 'abuse' => 'abuse@example.com', | ||
'hostmaster' => 'hostmaster@ | 'hostmaster' => 'hostmaster@example.com', | ||
'postmaster' => 'postmaster@ | 'postmaster' => 'postmaster@example.com', | ||
'webmaster' => 'webmaster@ | 'webmaster' => 'webmaster@example.com' | ||
); | ); | ||
// Questi sono gli alias che vengono creati per TUTTI i domini, se si sceglie di creare quelli default | // Questi sono gli alias che vengono creati per TUTTI i domini, se si sceglie di creare quelli default | ||
| Line 64: | Line 72: | ||
$CONF['domain_path'] = 'YES'; | $CONF['domain_path'] = 'YES'; | ||
$CONF['domain_in_mailbox'] = 'YES'; | $CONF['domain_in_mailbox'] = 'YES'; | ||
// Le caselle verranno create nel folder nomeuser@ | // Le caselle verranno create nel folder nomeuser@example.com | ||
$CONF['aliases'] = '0'; | $CONF['aliases'] = '0'; | ||
| Line 74: | Line 82: | ||
// link to display under 'Main' menu when logged in as a user. | // link to display under 'Main' menu when logged in as a user. | ||
$CONF['user_footer_link'] = "http://myserver.priv/postfixadmin"; | $CONF['user_footer_link'] = "http://myserver.example.priv/postfixadmin"; | ||
// Footer | // Footer | ||
| Line 81: | Line 89: | ||
$CONF['show_footer_text'] = 'YES'; | $CONF['show_footer_text'] = 'YES'; | ||
$CONF['footer_text'] = 'Return to Postfix Admin'; | $CONF['footer_text'] = 'Return to Postfix Admin'; | ||
$CONF['footer_link'] = 'http://myserver.priv/postfixadmin'; | $CONF['footer_link'] = 'http://myserver.example.priv/postfixadmin'; | ||
// Specify '' for Dovecot and 'INBOX.' for Courier. | // Specify '' for Dovecot and 'INBOX.' for Courier. | ||
| Line 90: | Line 98: | ||
// transport maps to handle virtual vacations. It does not need to be a | // transport maps to handle virtual vacations. It does not need to be a | ||
// real domain (i.e. you don't need to setup DNS for it). | // real domain (i.e. you don't need to setup DNS for it). | ||
$CONF['vacation_domain'] = 'autoreply. | $CONF['vacation_domain'] = 'autoreply.example.com'; | ||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ | /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ | ||
?> | |||
</pre> | |||
* Se si vuole attivare un forward direttamente da postfixadmin (Vedi [http://blog.illogicalextend.com/postfix-admin-aliases-for-existing-mailbox/ Postfix Admin Aliases for Existing Mailbox | Technical Blog of Ryan]: | |||
<pre> | |||
// Alias control for superadmins | |||
$CONF['alias_control'] = 'YES'; | |||
// Alias Control for domain admins | |||
$CONF['alias_control_admin'] = 'YES'; | |||
// Special Alias Control | |||
// Set to 'NO' if your domain admins shouldn't be able to edit the default aliases | |||
// as defined in $CONF['default_aliases'] | |||
$CONF['special_alias_control'] = 'YES'; | |||
</pre> | </pre> | ||
==Fix per Debian Buster== | |||
sed -i -e 's_Alias /postfixadmin /usr/share/postfixadmin_Alias /postfixadmin /usr/share/postfixadmin/public_' /etc/apache2/conf-enabled/postfixadmin.conf | |||
systemctl restart apache2 | |||
mkdir -p /usr/share/postfixadmin/lib/../templates_c | |||
chown www-data /usr/share/postfixadmin/lib/../templates_c -R | |||
chmod 700 /usr/share/postfixadmin/lib/../templates_c | |||
===Riferimenti=== | |||
*[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=926252 #926252 - postfixadmin: apache2 configuration does not point to public folder - Debian Bug report logs] | |||
*[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=926253 #926253 - postfixadmin: /usr/share/postfixadmin/lib/../templates_c does not exist on new installation - Debian Bug report logs] | |||
=Configurazione Web= | |||
* Andare alla pagina di setup, e controllare che tutto sia ok: | * Andare alla pagina di setup, e controllare che tutto sia ok: | ||
http://myserver.priv/postfixadmin/setup.php | http://myserver.example.priv/postfixadmin/setup.php | ||
* | * Via web, generare la password di setup, ed inserirla nel file di configurazione | ||
sudoedit /etc/postfixadmin/config.local.php | |||
$CONF['setup_password'] = 'f74986889643960430367b466d2575e6:537950f5dcb72607483e | $CONF['setup_password'] = 'f74986889643960430367b466d2575e6:537950f5dcb72607483e | ||
* Via Web, impostare le credenziali per l'utente amministratore | |||
* Fare login con email e password specificati | * Fare login con email e password specificati | ||
http://myserver.example.priv/postfixadmin/ | |||
* Creare il dominio ed uno user di test | * Creare il dominio ed uno user di test | ||
=Configurazione postfix= | =Configurazione postfix= | ||
* '''ATTENZIONE: ELIMINARE LA TRANSPORT_TABLE, PERCHÈ INTERFERISCE CON IL DELIVERY''' | |||
* Identificare uid e gid dello user postfix (tipicamente 101/101): | * Identificare uid e gid dello user postfix (tipicamente 101/101): | ||
id postfix | |||
uid=102(postfix) gid=105(postfix) groups=105(postfix) | |||
* Impostare i parametri | * Impostare i parametri di configurazione per i domini virtuali: | ||
<pre> | <pre> | ||
cat | sudo tee -a /etc/postfix/main.cf <<EOFile | cat | sudo tee -a /etc/postfix/main.cf <<EOFile | ||
virtual_uid_maps = static:$(id postfix -u) | |||
virtual_minimum_uid = $(id postfix -u) | |||
virtual_gid_maps = static:$(id postfix -g) | |||
virtual_transport = virtual | virtual_transport = virtual | ||
virtual_mailbox_base = /home/vmail | virtual_mailbox_base = /home/vmail | ||
| Line 134: | Line 175: | ||
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf | virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf | ||
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf | virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf | ||
relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf | |||
EOFile | EOFile | ||
</pre> | </pre> | ||
* | * Verificare | ||
sudoedit /etc/postfix/main.cf | sudoedit /etc/postfix/main.cf | ||
| Line 149: | Line 191: | ||
* Creare i file di configurazioni per le query SQL (cambiare la password) | * Creare i file di configurazioni per le query SQL (cambiare la password) | ||
* Alias map: | |||
<pre> | <pre> | ||
cat | sudo tee /etc/postfix/mysql_virtual_alias_maps.cf <<EOFile | cat | sudo tee /etc/postfix/mysql_virtual_alias_maps.cf <<EOFile | ||
user = postfixadmin | user = postfixadmin | ||
password = | password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
dbname = postfixadmin | dbname = postfixadmin | ||
| Line 159: | Line 202: | ||
EOFile | EOFile | ||
</pre> | </pre> | ||
* Verificare | |||
sudo cat /etc/postfix/mysql_virtual_alias_maps.cf | |||
'''NOTA: /etc/aliases servirà SOLO per gli alias LOCALI cioè le mail inviate a destinatari SENZA DOMINIO''' | '''NOTA: /etc/aliases servirà SOLO per gli alias LOCALI cioè le mail inviate a destinatari SENZA DOMINIO''' | ||
| Line 166: | Line 213: | ||
cat | sudo tee /etc/postfix/mysql_virtual_domains_maps.cf<<EOFile | cat | sudo tee /etc/postfix/mysql_virtual_domains_maps.cf<<EOFile | ||
user = postfixadmin | user = postfixadmin | ||
password = | password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
dbname = postfixadmin | dbname = postfixadmin | ||
| Line 175: | Line 222: | ||
</pre> | </pre> | ||
** Mailbox virtuali | |||
* Verificare: | |||
sudo cat /etc/postfix/mysql_virtual_domains_maps.cf | |||
* Mailbox virtuali | |||
<pre> | <pre> | ||
cat | sudo tee /etc/postfix/mysql_virtual_mailbox_maps.cf <<EOFile | cat | sudo tee /etc/postfix/mysql_virtual_mailbox_maps.cf <<EOFile | ||
user = postfixadmin | user = postfixadmin | ||
password = | password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
table = mailbox | table = mailbox | ||
| Line 188: | Line 240: | ||
</pre> | </pre> | ||
* | * Verificare: | ||
sudo cat /etc/postfix/mysql_virtual_mailbox_maps.cf | |||
* Backup MX relay_domains | |||
<pre> | <pre> | ||
cat | sudo tee /etc/postfix/mysql_relay_domains_maps.cf <<EOFile | |||
user = postfixadmin | |||
password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") | |||
hosts = 127.0.0.1 | |||
dbname = postfixadmin | |||
query = SELECT domain FROM domain WHERE domain='%s' AND backupmx='1' AND active='1' | |||
EOFile | |||
</pre> | </pre> | ||
sudo | * Verificare | ||
sudo cat /etc/postfix/mysql_relay_domains_maps.cf | |||
* Impostare permission: | |||
sudo chown postfix:postfix /etc/postfix/mysql_*.cf | |||
sudo chmod o-r /etc/postfix/mysql_*.cf | |||
* Creazione folders: | * Creazione folders: | ||
<pre> | <pre> | ||
sudo mkdir -p /home/vmail/ | sudo mkdir -p /home/vmail/example.com | ||
sudo chmod -R 770 /home/vmail | sudo chmod -R 770 /home/vmail | ||
sudo chown -R postfix:postfix /home/vmail/ | sudo chown -R postfix:postfix /home/vmail/ | ||
| Line 209: | Line 273: | ||
* Check config | * Check config | ||
sudo postconf | sudo postconf | ||
===Autenticazione SASL tramite Dovecot=== | |||
* Configurazione autenticazione SASL per postfix su dovecot | |||
sudoedit /etc/postfix/main.cf | |||
<pre> | |||
smtpd_sasl_auth_enable = yes | |||
smtpd_sasl_type = dovecot | |||
smtpd_sasl_path = private/auth | |||
</pre> | |||
systemctl restart postfix.service | |||
=Configurazione Dovecot= | =Configurazione Dovecot= | ||
| Line 285: | Line 362: | ||
sudo invoke-rc.d dovecot restart | sudo invoke-rc.d dovecot restart | ||
==Dovecot 2.x | ==Dovecot 2.x== | ||
* Installare i pacchetti: | |||
sudo apt-get install dovecot-imapd dovecot-mysql | |||
* Impostare autenticazione: | * Impostare autenticazione: | ||
sudoedit /etc/dovecot/conf.d/10 | sudoedit /etc/dovecot/conf.d/10-auth.conf | ||
disable_plaintext_auth = no | #disable_plaintext_auth = no | ||
#!include auth-system.conf.ext | |||
!include auth-sql.conf.ext | !include auth-sql.conf.ext | ||
* Impostare dettagli mailbox | * Impostare dettagli mailbox | ||
sudoedit /etc/dovecot/conf.d/10 | sudoedit /etc/dovecot/conf.d/10-mail.conf | ||
mail_location = maildir:/home/vmail/%d/%n | mail_location = maildir:/home/vmail/%d/%n | ||
* Impostare i valori corretti di uid e gui di postfix rilevati precedentemente: | |||
sudoedit /etc/dovecot/conf.d/10-mail.conf | |||
first_valid_uid = 102 | first_valid_uid = 102 | ||
| Line 305: | Line 390: | ||
mail_access_groups = mail | mail_access_groups = mail | ||
* Impostare i dettagli SQL '''ATTENZIONE, CONTROLLARE PASSWORD UID E GID NELLA QUERY''': | |||
<pre> | |||
cat | sudo tee -a /etc/dovecot/dovecot-sql.conf.ext <<EOFile | |||
driver = mysql | |||
connect = dbname=postfixadmin user=postfixadmin host=127.0.0.1 password=$(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") | |||
default_pass_scheme = MD5 | |||
password_query = \\ | |||
SELECT \\ | |||
password \\ | |||
FROM \\ | |||
mailbox \\ | |||
WHERE \\ | |||
username = '%u' | |||
user_query = \\ | |||
SELECT \\ | |||
CONCAT('/home/vmail/',maildir) AS home, \\ | |||
concat('maildir:/home/vmail/', maildir) as mail, \\ | |||
$(id postfix -u) AS uid, \\ | |||
$(id postfix -g) AS gid \\ | |||
FROM \\ | |||
mailbox \\ | |||
WHERE \\ | |||
username = '%u' | |||
EOFile | |||
</pre> | |||
sudoedit /etc/dovecot/dovecot-sql.conf.ext | |||
===Impostazione Autenticazione SASL tramite dovecot=== | |||
* Impostare l'autenticatore SASL usato per postfix: | * Impostare l'autenticatore SASL usato per postfix: | ||
sudoedit /etc/dovecot/conf.d/10-master.conf | sudoedit /etc/dovecot/conf.d/10-master.conf | ||
| Line 319: | Line 438: | ||
</pre> | </pre> | ||
* Impostare | * Impostare anche il metodo di autenticazione LOGI, altrimenti gli eventuali componenti DotNet smtp client non riusciranno ad autenticarsi | ||
sudoedit /etc/dovecot/conf.d/10-auth.conf | |||
auth_mechanisms = plain login | |||
* Ricordarsi di impostare anche Postifx per l'utilizzo di questo metodo di autenticazione sasl: [[Gestione domini virtual con postfixadmin#Autenticazione SASL tramite Dovecot|Autenticazione SASL tramite Dovecot in Postfix]] | |||
* Riavviare dovecot | |||
* Riavviare postfx | |||
* Testare invio mail autenticato | |||
===Riferimenti=== | |||
*[http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL HowTo/PostfixAndDovecotSASL - Dovecot Wiki] | |||
*[http://serverfault.com/questions/463812/postfix-auth-login-no-longer-being-offered-for-smtp-auth-after-upgrade-from-ub dovecot - Postfix "AUTH-LOGIN" no longer being offered for smtp auth after upgrade from Ubuntu 10.04 to 12.04.1 - Server Fault] | |||
=Upgrade= | =Upgrade= | ||
| Line 372: | Line 479: | ||
*[http://wiki2.dovecot.org/HowTo/DovecotLDAPostfixAdminMySQL HowTo/DovecotLDAPostfixAdminMySQL - Dovecot Wiki] | *[http://wiki2.dovecot.org/HowTo/DovecotLDAPostfixAdminMySQL HowTo/DovecotLDAPostfixAdminMySQL - Dovecot Wiki] | ||
*[http://linux.justinhartman.com/Postfix_and_Courier_Installation_using_MySQL#Configure_Saslauthd Postfix and Courier Installation using MySQL - Debian Wiki] | *[http://linux.justinhartman.com/Postfix_and_Courier_Installation_using_MySQL#Configure_Saslauthd Postfix and Courier Installation using MySQL - Debian Wiki] | ||
[[Category:Published]] | |||
Latest revision as of 15:08, 19 October 2020
Il pacchetto .deb di postfixadmin è stato inserito nel repository RVM. Alternativamente scaricarlo ed installarlo a mano
Installazione
Debian >= Jessie
- Il pacchetto è standard Debian:
sudo apt-get install postfixadmin
Debian < Jessie
- Scaricare il .deb da sourceforge Postfix Admin - Browse /postfixadmin at SourceForge.net
- Attualmente l'ultima versione stabile è postfixadmin_2.3.7-1_all.deb
sudo dpkg -i install postfixadmin_2.3.7-1_all.deb
- Installare le dipendenze necessarie:
sudo apt-get install -f
Configurazione del Database
Configurazione con db-config-common
- Con questa modalità di configurazione, la parte database viene già configurata.
Configurazione database manuale
- Creare il database
postfixadmin
- Creare lo user con tutti i diritti sul db postfixadmin
postfixadmin/postfixpassword
- Modificare i parametri di configurazione:
cd /etc/postfixadmin sudoedit /etc/postfixadmin/config.inc.php
$CONF['database_type'] = 'mysqli'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfixadmin'; $CONF['database_password'] = 'postfixpassword'; $CONF['database_name'] = 'postfixadmin'; $CONF['database_prefix'] = ''; // Impostazioni DB
Preconfigurazione
- Impostare questi parametri prima di procedere alla configurazione via web:
sudoedit /etc/postfixadmin/config.local.php
<?php
$CONF['postfix_admin_url'] = 'http://myserver.example.priv/postfixadmin';
// URL per far funzionare i link interni
$CONF['default_language'] = 'it';
// Lingua di default dell'interfaccia web
$CONF['admin_email'] = 'admin@example.com';
// Il login inziale dell'utente amministrativo
$CONF['encrypt'] = 'md5crypt';
//Usiamo md5, compatibile con Postfix e con l'autenticazione Sasl di dovecot
// NON È COMPATIBILE CON L'AUTENTICAZIONE SASL STANDARD
$CONF['default_aliases'] = array (
'abuse' => 'abuse@example.com',
'hostmaster' => 'hostmaster@example.com',
'postmaster' => 'postmaster@example.com',
'webmaster' => 'webmaster@example.com'
);
// Questi sono gli alias che vengono creati per TUTTI i domini, se si sceglie di creare quelli default
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'YES';
// Le caselle verranno create nel folder nomeuser@example.com
$CONF['aliases'] = '0';
$CONF['mailboxes'] = '0';
$CONF['maxquota'] = '0';
// Di default non creare gli alias di default, nessun amailbox di default e non abilitare la quota.
$CONF['create_mailbox_subdirs_prefix']='';
// link to display under 'Main' menu when logged in as a user.
$CONF['user_footer_link'] = "http://myserver.example.priv/postfixadmin";
// Footer
// Below information will be on all pages.
// If you don't want the footer information to appear set this to 'NO'.
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to Postfix Admin';
$CONF['footer_link'] = 'http://myserver.example.priv/postfixadmin';
// Specify '' for Dovecot and 'INBOX.' for Courier.
$CONF['create_mailbox_subdirs_prefix']='';
$CONF['vacation'] = 'YES';
// This is the autoreply domain that you will need to set in your Postfix
// transport maps to handle virtual vacations. It does not need to be a
// real domain (i.e. you don't need to setup DNS for it).
$CONF['vacation_domain'] = 'autoreply.example.com';
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
?>
- Se si vuole attivare un forward direttamente da postfixadmin (Vedi Postfix Admin Aliases for Existing Mailbox | Technical Blog of Ryan:
// Alias control for superadmins $CONF['alias_control'] = 'YES'; // Alias Control for domain admins $CONF['alias_control_admin'] = 'YES'; // Special Alias Control // Set to 'NO' if your domain admins shouldn't be able to edit the default aliases // as defined in $CONF['default_aliases'] $CONF['special_alias_control'] = 'YES';
Fix per Debian Buster
sed -i -e 's_Alias /postfixadmin /usr/share/postfixadmin_Alias /postfixadmin /usr/share/postfixadmin/public_' /etc/apache2/conf-enabled/postfixadmin.conf
systemctl restart apache2
mkdir -p /usr/share/postfixadmin/lib/../templates_c chown www-data /usr/share/postfixadmin/lib/../templates_c -R chmod 700 /usr/share/postfixadmin/lib/../templates_c
Riferimenti
- #926252 - postfixadmin: apache2 configuration does not point to public folder - Debian Bug report logs
- #926253 - postfixadmin: /usr/share/postfixadmin/lib/../templates_c does not exist on new installation - Debian Bug report logs
Configurazione Web
- Andare alla pagina di setup, e controllare che tutto sia ok:
http://myserver.example.priv/postfixadmin/setup.php
- Via web, generare la password di setup, ed inserirla nel file di configurazione
sudoedit /etc/postfixadmin/config.local.php
$CONF['setup_password'] = 'f74986889643960430367b466d2575e6:537950f5dcb72607483e
- Via Web, impostare le credenziali per l'utente amministratore
- Fare login con email e password specificati
http://myserver.example.priv/postfixadmin/
- Creare il dominio ed uno user di test
Configurazione postfix
- ATTENZIONE: ELIMINARE LA TRANSPORT_TABLE, PERCHÈ INTERFERISCE CON IL DELIVERY
- Identificare uid e gid dello user postfix (tipicamente 101/101):
id postfix uid=102(postfix) gid=105(postfix) groups=105(postfix)
- Impostare i parametri di configurazione per i domini virtuali:
cat | sudo tee -a /etc/postfix/main.cf <<EOFile virtual_uid_maps = static:$(id postfix -u) virtual_minimum_uid = $(id postfix -u) virtual_gid_maps = static:$(id postfix -g) virtual_transport = virtual virtual_mailbox_base = /home/vmail virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf EOFile
- Verificare
sudoedit /etc/postfix/main.cf
- Eliminare i domini virtuali dai parametri
mydestination relay_domains
sudoedit /etc/postfix/main.cf
- Creare i file di configurazioni per le query SQL (cambiare la password)
- Alias map:
cat | sudo tee /etc/postfix/mysql_virtual_alias_maps.cf <<EOFile user = postfixadmin password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") hosts = 127.0.0.1 dbname = postfixadmin query = SELECT goto FROM alias WHERE address='%s' AND active = '1' EOFile
- Verificare
sudo cat /etc/postfix/mysql_virtual_alias_maps.cf
NOTA: /etc/aliases servirà SOLO per gli alias LOCALI cioè le mail inviate a destinatari SENZA DOMINIO
- Domini virtuali considerati locali:
cat | sudo tee /etc/postfix/mysql_virtual_domains_maps.cf<<EOFile user = postfixadmin password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") hosts = 127.0.0.1 dbname = postfixadmin #query = SELECT domain FROM domain WHERE domain='%s' #optional query to use when relaying for backup MX query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' EOFile
- Verificare:
sudo cat /etc/postfix/mysql_virtual_domains_maps.cf
- Mailbox virtuali
cat | sudo tee /etc/postfix/mysql_virtual_mailbox_maps.cf <<EOFile user = postfixadmin password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") hosts = 127.0.0.1 table = mailbox dbname = postfixadmin query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1' #query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1' EOFile
- Verificare:
sudo cat /etc/postfix/mysql_virtual_mailbox_maps.cf
- Backup MX relay_domains
cat | sudo tee /etc/postfix/mysql_relay_domains_maps.cf <<EOFile user = postfixadmin password = $(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'") hosts = 127.0.0.1 dbname = postfixadmin query = SELECT domain FROM domain WHERE domain='%s' AND backupmx='1' AND active='1' EOFile
- Verificare
sudo cat /etc/postfix/mysql_relay_domains_maps.cf
- Impostare permission:
sudo chown postfix:postfix /etc/postfix/mysql_*.cf sudo chmod o-r /etc/postfix/mysql_*.cf
- Creazione folders:
sudo mkdir -p /home/vmail/example.com sudo chmod -R 770 /home/vmail sudo chown -R postfix:postfix /home/vmail/
- Check config
sudo postconf
Autenticazione SASL tramite Dovecot
- Configurazione autenticazione SASL per postfix su dovecot
sudoedit /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth
systemctl restart postfix.service
Configurazione Dovecot
Dovecot 1.x (Squeeze)
sudoedit /etc/dovecot/dovecot-sql.conf
driver = mysql
connect = dbname=postfixadmin user=postfixadmin host=127.0.0.1 password=postfixpassword
default_pass_scheme = MD5
password_query = \
SELECT \
password \
FROM \
mailbox \
WHERE \
username = '%u'
user_query = \
SELECT \
CONCAT('/home/vmail/',maildir) AS home, \
concat('maildir:/home/vmail/', maildir) as mail, \
101 AS uid, \
101 AS gid \
FROM \
mailbox \
WHERE \
username = '%u'
sudoedit /etc/dovecot/dovecot.conf
protocols = imap imaps pop3 pop3s
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n
mail_access_groups = mail
first_valid_uid = 102
first_valid_gid = 105
protocol imap {
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}
auth default {
mechanisms = digest-md5 plain login
passdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
userdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
user = root
socket listen {
client {
# The client socket is generally safe to export to everyone. Typical use
# is to export it to your SMTP server so it can do SMTP AUTH lookups
# using it.
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}
}
sudo invoke-rc.d dovecot restart
Dovecot 2.x
- Installare i pacchetti:
sudo apt-get install dovecot-imapd dovecot-mysql
- Impostare autenticazione:
sudoedit /etc/dovecot/conf.d/10-auth.conf
#disable_plaintext_auth = no
#!include auth-system.conf.ext !include auth-sql.conf.ext
- Impostare dettagli mailbox
sudoedit /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/home/vmail/%d/%n
- Impostare i valori corretti di uid e gui di postfix rilevati precedentemente:
sudoedit /etc/dovecot/conf.d/10-mail.conf
first_valid_uid = 102
first_valid_gid = 105
mail_access_groups = mail
- Impostare i dettagli SQL ATTENZIONE, CONTROLLARE PASSWORD UID E GID NELLA QUERY:
cat | sudo tee -a /etc/dovecot/dovecot-sql.conf.ext <<EOFile
driver = mysql
connect = dbname=postfixadmin user=postfixadmin host=127.0.0.1 password=$(sudo cat /etc/dbconfig-common/postfixadmin.conf | grep -v '#' | grep dbc_dbpass| cut -f 2 --delimiter='=' | tr -d "'")
default_pass_scheme = MD5
password_query = \\
SELECT \\
password \\
FROM \\
mailbox \\
WHERE \\
username = '%u'
user_query = \\
SELECT \\
CONCAT('/home/vmail/',maildir) AS home, \\
concat('maildir:/home/vmail/', maildir) as mail, \\
$(id postfix -u) AS uid, \\
$(id postfix -g) AS gid \\
FROM \\
mailbox \\
WHERE \\
username = '%u'
EOFile
sudoedit /etc/dovecot/dovecot-sql.conf.ext
Impostazione Autenticazione SASL tramite dovecot
- Impostare l'autenticatore SASL usato per postfix:
sudoedit /etc/dovecot/conf.d/10-master.conf
...
service auth {
...
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
}
...
- Impostare anche il metodo di autenticazione LOGI, altrimenti gli eventuali componenti DotNet smtp client non riusciranno ad autenticarsi
sudoedit /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login
- Ricordarsi di impostare anche Postifx per l'utilizzo di questo metodo di autenticazione sasl: Autenticazione SASL tramite Dovecot in Postfix
- Riavviare dovecot
- Riavviare postfx
- Testare invio mail autenticato
Riferimenti
- HowTo/PostfixAndDovecotSASL - Dovecot Wiki
- dovecot - Postfix "AUTH-LOGIN" no longer being offered for smtp auth after upgrade from Ubuntu 10.04 to 12.04.1 - Server Fault
Upgrade
- La nuova versione gestisce il database con dbconfig-common
- Per migrare, impostare la password in
/etc/dbconfig-common/postfixadmin.conf
- Aggiornare la configurazione:
sudo /usr/sbin/dbconfig-generate-include -f php /etc/dbconfig-common/postfixadmin.conf /etc/postfixadmin/dbconfig.inc.php
- Impostare le permission
sudo chown :www-data /etc/postfixadmin/dbconfig.inc.php sudo chmod g+r /etc/postfixadmin/dbconfig.inc.php
Riferimenti
- Postfix, virtual domain setup - FreeBSDwiki
- postfix - SASL + postfixadmin - SMTP authentication with hashed password - Server Fault
- Jitamitra: Configure Postfix, Postfixadmin, Dovecot On Debian & Ubuntu
- v2p1 Mail server Debian Lenny Postfix Virtual PostfixAdmin MySQL Dovecot Amavisd-new SquirrelMail MailZu
- Postfixadmin – setup/install guide for virtual mail users on Postfix | David Goodwin
- SourceForge.net: Postfixadmin-CLI - postfixadmin
- HowTo/DovecotLDAPostfixAdminMySQL - Dovecot Wiki
- Postfix and Courier Installation using MySQL - Debian Wiki