|
|
(33 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
Zeile 144: |
Zeile 144: |
| 'webmaster' => 'webmaster@<domain>' | | 'webmaster' => 'webmaster@<domain>' |
| ); | | ); |
| | |
| | // If you want to use virtual vacation for you mailbox users set this to 'YES'. |
| | // NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/) |
| | $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). |
| | // This domain must exclusively be used for vacation. Do NOT use it for "normal" mail addresses. |
| | $CONF['vacation_domain'] = 'autoreply.<domain>'; |
| ?> | | ?> |
| </pre> | | </pre> |
Zeile 153: |
Zeile 163: |
| [http://10.0.0.120/postfixadmin/setup.php http://10.0.0.120/postfixadmin/setup.php] | | [http://10.0.0.120/postfixadmin/setup.php http://10.0.0.120/postfixadmin/setup.php] |
|
| |
|
| === Verzeichnisse automatisch erstellen bzw. löschen === | | === Default Aliases === |
|
| |
|
| {{note|Der Benutzer ''vmail'' muss bereits angelegt sein - siehe dazu die Seite ''Dovecot''.}}
| | Die Datei <code>config.local.php</code> editieren |
|
| |
|
| Verzeichnisse für die gelöschten Daten erstellen:
| |
| <pre> | | <pre> |
| sudo mkdir /var/vmail-deleted | | sudo vi /var/www/postfixadmin/config.local.php |
| sudo chown vmail:vmail /var/vmail-deleted
| |
| sudo mkdir /home/vmail-deleted
| |
| sudo chown vmail:vmail /home/vmail-deleted
| |
| </pre> | | </pre> |
|
| |
|
| ==== Maildir erstellen ====
| | und am Ende folgende Zeilen hinzufügen: |
|
| |
|
| In der Datei ''/var/www/postfixadmin/config.local.php'' folgende Zeilen einfügen:
| |
| <pre> | | <pre> |
| $CONF['mailbox_postcreation_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postcreation.sh';
| | // Default Aliases |
| $CONF['mailbox_postdeletion_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postdeletion.sh'; | | // The default aliases that need to be created for all domains. |
| $CONF['domain_postdeletion_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-domain-postdeletion.sh';
| | // You can specify the target address in two ways: |
| | // a) a full mail address |
| | // b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain |
| | $CONF['default_aliases'] = array ( |
| | 'abuse' => 'abuse@<domain>', |
| | 'hostmaster' => 'hostmaster@<domain>', |
| | 'postmaster' => 'postmaster@<domain>', |
| | 'webmaster' => 'webmaster@<domain>' |
| | ); |
| </pre> | | </pre> |
|
| |
|
| Die Scripte dafür liegen bereits in ''$DOCUMENT_ROOT/ADDITIONS'' und müssen nur noch ins ''cgi-bin''-Verzeichnis kopiert werden:
| | === Verzeichnisse automatisch erstellen bzw. löschen === |
| <pre>
| |
| sudo cp /var/www/postfixadmin/ADDITIONS/postfixadmin-mailbox-postcreation.sh /usr/local/bin/
| |
| sudo cp /var/www/postfixadmin/ADDITIONS/postfixadmin-mailbox-postdeletion.sh /usr/local/bin/
| |
| sudo cp /var/www/postfixadmin/ADDITIONS/postfixadmin-domain-postdeletion.sh /usr/local/bin/
| |
| sudo chown root:vmail /usr/local/bin/postfixadmin-*-post*.sh
| |
| sudo chmod 750 /usr/local/bin/postfixadmin-*-post*.sh
| |
| </pre>
| |
| | |
| Datei ''/etc/sudoers'' bearbeiten (nicht direkt, sondern über ''visudo'' - macht einen Syntax-Check):
| |
| <pre>
| |
| sudo visudo
| |
| </pre>
| |
| | |
| Am Ende folgende Zeilen einfügen:
| |
| <pre>
| |
| # Allow postfixadmin to create/delete maildirs
| |
| www-data ALL=(vmail) NOPASSWD: /usr/local/bin/postfixadmin-mailbox-postcreation.sh
| |
| www-data ALL=(vmail) NOPASSWD: /usr/local/bin/postfixadmin-mailbox-postdeletion.sh
| |
| www-data ALL=(vmail) NOPASSWD: /usr/local/bin/postfixadmin-domain-postdeletion.sh
| |
| </pre>
| |
| Das erlaubt dem Benutzer ''www-data'' die hinzugefügten Skripte als Benutzer ''vmail'' '''ohne''' Passwortabfrage auszuführen.
| |
| | |
| | |
| In der Datei ''/usr/local/bin/postfixadmin-mailbox-postcreation.sh'' folgende Zeilen anpassen:
| |
| <pre>
| |
| basedir=/var/vmail
| |
| maildirmake.dovecot "$maildir"
| |
| </pre>
| |
| | |
| In der Datei ''/usr/local/bin/postfixadmin-mailbox-postdeletion.sh'' folgende Zeilen anpassen:
| |
| <pre>
| |
| basedir=/var/vmail
| |
| trashbase=/var/vmail-deleted
| |
| </pre>
| |
| | |
| In der Datei ''/usr/local/bin/postfixadmin-domain-postdeletion.sh'' folgende Zeilen anpassen:
| |
| <pre>
| |
| basedir=/var/vmail
| |
| trashbase=/var/vmail-deleted
| |
| </pre>
| |
| | |
| ==== Homedir ====
| |
| | |
| Zuerst legen wir ein Verzeignis für die Logdatei an:
| |
| <pre>
| |
| sudo mkdir -p /home/vmail/logs/
| |
| sudo chown -R vmail:vmail /home/vmail/
| |
| </pre>
| |
| | |
| ===== anlegen =====
| |
| | |
| Ähnlich dem ursprünglichen Skript ''postfixadmin-mailbox-postcreation.sh'' legen wir ein neues Skipt ''postfixadmin-homedir-postcreation.sh'' an:
| |
| <pre>
| |
| sudo vi /usr/local/bin/postfixadmin-homedir-postcreation.sh
| |
| </pre>
| |
| | |
| Dieses neue Skript wird mit folgenden Inhalt befüllt:
| |
| <pre>
| |
| #!/bin/sh
| |
| | |
| # Change this to where you keep your virtual mail logfiles.
| |
| errorlog=/home/vmail/logs/error.log
| |
| | |
| # Change this to where you keep your virtual mail users' homedirs.
| |
| basedir=/home/vmail
| |
| | |
| if [ ! -e "$basedir" ]; then
| |
| echo "$0: basedir '$basedir' does not exist; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| # create directory /home/vmail/<new user>/
| |
| current="${basedir}/$1"
| |
| mkdir -p "${current}"
| |
| if [ $? -ne 0 ]; then
| |
| echo "$0: mkdir -p '$current' returned non-zero; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| # create directory /home/vmail/<new user>/sieve/
| |
| current="${current}/sieve"
| |
| mkdir -p "${current}"
| |
| if [ $? -ne 0 ]; then
| |
| echo "$0: mkdir -p '$current' returned non-zero; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| # create directory /home/vmail/<new user>/sieve/scripts/
| |
| current="${current}/scripts"
| |
| mkdir -p "${current}"
| |
| if [ $? -ne 0 ]; then
| |
| echo "$0: mkdir -p '$current' returned non-zero; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| exit 0
| |
| </pre>
| |
| | |
| Das Skript noch ausführbar machen und Besitzer ändern:
| |
| <pre>
| |
| sudo chmod 750 /usr/local/bin/postfixadmin-homedir-postcreation.sh
| |
| sudo chown root:vmail /usr/local/bin/postfixadmin-homedir-postcreation.sh
| |
| </pre>
| |
| | |
| Das fertige Skript wird dann im ursprünglichen Skript ''postfixadmin-mailbox-postcreation.sh'' aufgerufen:
| |
| <pre>
| |
| sudo vi /usr/local/bin/postfixadmin-mailbox-postcreation.sh
| |
| </pre>
| |
| | |
| Dazu am Ende der Datei anstelle von ''exit 0'' folgende Zeilen einfügen:
| |
| <pre>
| |
| # create home directory
| |
| `dirname "$0"`/postfixadmin-homedir-postcreation.sh `basename "$3"`
| |
| exit $?
| |
| </pre>
| |
| | |
| ===== löschen =====
| |
| | |
| Ähnlich dem ursprünglichen Skript ''postfixadmin-mailbox-postdeletion.sh'' legen wir ein neues Skipt ''postfixadmin-homedir-postdeletion.sh'' an:
| |
| <pre>
| |
| sudo vi /usr/local/bin/postfixadmin-homedir-postdeletion.sh
| |
| </pre>
| |
| | |
| Dieses neue Skript wird mit folgenden Inhalt befüllt:
| |
| <pre>
| |
| #!/bin/sh
| |
| | |
| # Change this to where you keep your virtual mail logfiles.
| |
| errorlog=/home/vmail/logs/error.log
| |
| | |
| # Change this to where you keep your virtual mail users' homedirs.
| |
| basedir=/home/vmail
| |
| | |
| # Change this to where you would like deleted homedirs to reside.
| |
| trashbase=/home/vmail-deleted
| |
| | |
| | |
| if [ ! -e "$trashbase" ]; then
| |
| echo "trashbase '$trashbase' does not exist; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| if [ `echo $1 | fgrep '..'` ]; then
| |
| echo "First argument contained a double-dot sequence; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| subdir=`echo "$1" | sed 's/@.*//'`
| |
| | |
| homedir="${basedir}/${subdir}"
| |
| trashdir="${trashbase}/`date +%F_%T`_${subdir}"
| |
| | |
| parent=`dirname "$trashdir"`
| |
| if [ ! -d "$parent" ]; then
| |
| if [ -e "$parent" ]; then
| |
| echo "Strainge - directory '$parent' exists, but is not a directory." >> $errorlog
| |
| echo "Bailing out." >> $basedir/logs/error.log
| |
| exit 1
| |
| else
| |
| mkdir -p "$parent"
| |
| if [ $? -ne 0 ]; then
| |
| echo "mkdir -p '$parent' returned non-zero; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| fi
| |
| fi
| |
| | |
| if [ ! -e "$homedir" ]; then
| |
| echo "homedir '$homedir' does not exist; nothing to do." >> $errorlog
| |
| exit 1
| |
| fi
| |
| if [ -e "$trashdir" ]; then
| |
| echo "homedir '$trashdir' already exists; bailing out." >> $errorlog
| |
| exit 1
| |
| fi
| |
| | |
| mv $homedir $trashdir
| |
| | |
| exit $?
| |
| </pre>
| |
| | |
| Das Skript noch ausführbar machen und Benutzer ändern:
| |
| <pre>
| |
| sudo chmod 750 /usr/local/bin/postfixadmin-homedir-postdeletion.sh
| |
| sudo chown root:vmail /usr/local/bin/postfixadmin-homedir-postdeletion.sh
| |
| </pre>
| |
|
| |
|
| Das fertige Skript wird dann im ursprünglichen Skript ''postfixadmin-mailbox-postdeletion.sh'' aufgerufen:
| | Siehe dazu [[PostfixAdmin Verzeichnisverwaltung (Ubuntu 16.04)|PostfixAdmin Verzeichnisverwaltung]] |
| <pre>
| |
| sudo vi /usr/local/bin/postfixadmin-mailbox-postdeletion.sh
| |
| </pre>
| |
|
| |
|
| Dazum am Ende der Datei anstelle von ''exit $?'' folgende Zeilen einfügen:
| | === Automatische Urlaub Antwortmails === |
| <pre>
| |
| if [ $? -ne 0 ]; then
| |
| echo "mv $maildir $trashdir returned non-zero; bailing out."
| |
| exit 1
| |
| fi
| |
|
| |
|
| # delete home directory
| | Siehe dazu [[PostfixAdmin Autoresponder (Ubuntu 16.04)|PostfixAdmin Autoresponder]] |
| `dirname "$0"`/postfixadmin-homedir-postdeletion.sh `basename "$1"`
| |
| exit $?
| |
| </pre>
| |
|
| |
|
| === Fetchmail === | | === Fetchmail === |
|
| |
|
| [[Fetchmail (Ubuntu 16.04)|Fetchmail]] muss bereits installiert sein. | | Siehe dazu [[PostfixAdmin Fetchmail (Ubuntu 16.04)|PostfixAdmin Fetchmail]] |
| | |
| ==== Daemon deaktivieren ====
| |
| | |
| In der Datei ''/etc/default/fetchmail'' folgende Zeile anpassen:
| |
| <pre>
| |
| sudo vi /etc/default/fetchmail
| |
| </pre>
| |
| | |
| <pre>
| |
| START_DAEMON=no
| |
| </pre>
| |
| | |
| Danach ''fetchmail'' stoppen:
| |
| <pre>
| |
| sudo /etc/init.d/fetchmail stop
| |
| </pre>
| |
| | |
| ==== Abhängigkeiten ====
| |
| | |
| <pre>
| |
| sudo apt-get update
| |
| sudo apt-get install liblockfile-simple-perl
| |
| </pre>
| |
| | |
| ==== Script ''fetchmail.pl'' ====
| |
| | |
| Fertiges Script von ''/<document root>/ADDITIONS/'' nach ''/usr/local/bin/'' kopieren:
| |
| <pre>
| |
| sudo cp /var/www/postfixadmin/ADDITIONS/fetchmail.pl /usr/local/bin/
| |
| sudo chown root:vmail /usr/local/bin/fetchmail.pl
| |
| sudo chmod 750 /usr/local/bin/fetchmail.pl
| |
| </pre>
| |
| | |
| In der Datei ''fetchmail.pl'' folgende Werte anpassen:
| |
| <pre>
| |
| sudo nano /usr/local/bin/fetchmail.pl
| |
| </pre>
| |
| | |
| <pre>
| |
| # database backend
| |
| $db_type = 'mysql';
| |
| # host name
| |
| $db_host="<server ip>";
| |
| # database name
| |
| $db_name="postfix";
| |
| # database username
| |
| $db_username="postfix";
| |
| # database password
| |
| $db_password="<password>";
| |
| </pre>
| |
| | |
| ==== ''Lock''-Datei anlegen ====
| |
| | |
| <pre>
| |
| sudo -u vmail mkdir /home/vmail/fetchmail/
| |
| sudo -u vmail touch /home/vmail/fetchmail/fetchmail-all.lock
| |
| </pre>
| |
| | |
| <pre>
| |
| sudo vi /usr/local/bin/fetchmail.pl
| |
| </pre>
| |
| | |
| Pfad zur ''Lock''-Datei von
| |
| | |
| <pre>
| |
| $run_dir="/var/run/fetchmail";
| |
| </pre>
| |
| | |
| nach
| |
| | |
| <pre>
| |
| $run_dir="/home/vmail/fetchmail";
| |
| </pre>
| |
| | |
| ändern, da ''/var/run/'' bei jedem Neustart geleert wird.
| |
| | |
| ==== Cronjob anlegen ====
| |
| | |
| <pre>
| |
| sudo crontab -e
| |
| </pre>
| |
| | |
| <pre>
| |
| */1 * * * * sudo -H -u vmail /usr/local/bin/fetchmail.pl > /dev/null 2&>1
| |
| </pre>
| |
|
| |
|
| == Probleme == | | == Probleme == |
Voraussetzungen
LAMP-Server, dazu siehe auch: Apache, MySQL
Installation
PHP
sudo apt-get install php-imap
sudo service apache2 restart
tar-Verzeichnis
Aktuelle Version unter https://sourceforge.net/projects/postfixadmin/files/postfixadmin herunterladen.
wget https://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-3.1/postfixadmin-3.1.tar.gz
tar -xzf postfixadmin-3.1.tar.gz
sudo mv postfixadmin-3.1 /var/www/postfixadmin/
sudo chown -R www-data:www-data /var/www/postfixadmin/
sudo -u www-data mkdir /var/www/postfixadmin/templates_c
In dem entpackten Verzeichnis befindet sich auch eine Datei Install.txt, wo die grundlegenden Schritte beschrieben werden.
MySQL
mysql -u root -p
mysql> create database if not exists postfix;
mysql> create user 'postfix'@'%' identified by '<password>';
mysql> grant all privileges on postfix.* to 'postfix'@'%';
mysql> flush privileges;
mysql> quit;
Konfiguration
Apache2
cd /etc/apache2/conf-available/
sudo vi /etc/apache2/conf-available/postfixadmin.conf
Alias /postfixadmin "/var/www/postfixadmin/"
<Directory "/var/www/postfixadmin">
Options +FollowSymLinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/postfixadmin
SetEnv HTTP_HOME /var/www/postfixadmin
</Directory>
sudo a2enconf postfixadmin
sudo service apache2 reload
PostfixAdmin
Grundkonfiguration
Konfigurationsdatei anlegen (überschreibt die Standardwerte in config.inc.php):
cd /var/www/postfixadmin/
sudo -u www-data vi config.local.php
Datei sollte in der Grundkonfiguration etwa so aussehen:
<?php
$CONF['configured'] = true;
$CONF['database_type'] = 'mysqli';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = '<password>';
$CONF['database_name'] = 'postfix';
?>
Nach Abschluss aller Konfigurationen sollte die Datei dann so aussehen:
<?php
$CONF['configured'] = true;
$CONF['setup_password'] = '<setup password>';
$CONF['default_language'] = 'de';
$CONF['database_type'] = 'mysql';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = '<database password>';
$CONF['database_name'] = 'postfix';
$CONF['admin_email'] = '<mail address>';
$CONF['encrypt'] = 'dovecot:SHA512-CRYPT';
$CONF['dovecotpw'] = "/usr/bin/doveadm pw";
$CONF['transport'] = 'YES';
$CONF['default_aliasis'] = array (
'abuse' => '<mail address>',
'hostmaster' => '<mail address>',
'postmaster' => '<mail address>',
'webmaster' => '<mail address>'
);
$CONF['password_validation'] = array(
# '/regular expression/' => '$PALANG key (optional: + parameter)',
'/.{5}/' => 'password_too_short 5', # minimum length 5 characters
'/([a-zA-Z].*){3}/' => 'password_no_characters 3', # must contain at least 3 characters
'/([0-9].*){1}/' => 'password_no_digits 1', # must contain at least 1 digit(s)
);
$CONF['aliases'] = '100';
$CONF['mailboxes'] = '100';
$CONF['maxquota'] = '100';
$CONF['domain_quota_default'] = '2048';
$CONF['footer_text'] = 'Return to mail.<domain>';
$CONF['footer_link'] = 'https://mail.<domain>';
$CONF['mailbox_postcreation_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postcreation.sh';
$CONF['mailbox_postdeletion_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-mailbox-postdeletion.sh';
$CONF['domain_postdeletion_script'] = 'sudo -u vmail /usr/local/bin/postfixadmin-domain-postdeletion.sh';
// Default Aliases
// The default aliases that need to be created for all domains.
// You can specify the target address in two ways:
// a) a full mail address
// b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain
$CONF['default_aliases'] = array (
'abuse' => 'abuse@<domain>',
'hostmaster' => 'hostmaster@<domain>',
'postmaster' => 'postmaster@<domain>',
'webmaster' => 'webmaster@<domain>'
);
// If you want to use virtual vacation for you mailbox users set this to 'YES'.
// NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/)
$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).
// This domain must exclusively be used for vacation. Do NOT use it for "normal" mail addresses.
$CONF['vacation_domain'] = 'autoreply.<domain>';
?>
Setup aufrufen
Wenn die Grundkonfiguration abgeschlossen ist, wird das Setup-Script aufgerufen:
http://10.0.0.120/postfixadmin/setup.php
Default Aliases
Die Datei config.local.php
editieren
sudo vi /var/www/postfixadmin/config.local.php
und am Ende folgende Zeilen hinzufügen:
// Default Aliases
// The default aliases that need to be created for all domains.
// You can specify the target address in two ways:
// a) a full mail address
// b) only a localpart ('postmaster' => 'admin') - the alias target will point to the same domain
$CONF['default_aliases'] = array (
'abuse' => 'abuse@<domain>',
'hostmaster' => 'hostmaster@<domain>',
'postmaster' => 'postmaster@<domain>',
'webmaster' => 'webmaster@<domain>'
);
Verzeichnisse automatisch erstellen bzw. löschen
Siehe dazu PostfixAdmin Verzeichnisverwaltung
Automatische Urlaub Antwortmails
Siehe dazu PostfixAdmin Autoresponder
Fetchmail
Siehe dazu PostfixAdmin Fetchmail
Probleme
the templates_c directory doesn’t exist or isn’t writeable for the webserver
Einfach ein leeres Verzeichnis template_c
unter /var/www/postfixadmin/
anlegen.
Links
http://blog.cboltz.de/uploads/postfixadmin-30-english.pdf
Zurück zu Dovecot
Zurück zu Mailserver einrichten