Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:postfix_amavis_mailzu_installieren

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
tachtler:postfix_amavis_mailzu_installieren [2013/03/22 09:32] – [Postfix AMaViS MailZu Fehlerbehebung] klaustachtler:postfix_amavis_mailzu_installieren [2013/12/08 10:30] (aktuell) – [Postfix AMaViS MailZu deutsche Sprachdatei] klaus
Zeile 110: Zeile 110:
   * **''/etc/amavisd.conf''**   * **''/etc/amavisd.conf''**
 von [[http://www.ijs.si/software/amavisd/|AMaViS]] (//A MAil Virus Scanner//) sind notwendig, um [[http://sourceforge.net/projects/mailzu/|MailZu]] in vollem Umfang nutzen zu können (**nur relevanter Ausschnitt**): von [[http://www.ijs.si/software/amavisd/|AMaViS]] (//A MAil Virus Scanner//) sind notwendig, um [[http://sourceforge.net/projects/mailzu/|MailZu]] in vollem Umfang nutzen zu können (**nur relevanter Ausschnitt**):
-<code ini>+<code php>
 ... ...
 # Tachtler - MailZu # Tachtler - MailZu
Zeile 126: Zeile 126:
 }; };
 ... ...
-...+# Tachtler - MailZu 
 +@lookup_sql_dsn = 
 +  ( ['DBI:mysql:database=amavis;host=192.168.0.30;port=3306', 'amavis', 'geheim'] ); 
 +@storage_sql_dsn = @lookup_sql_dsn;  # none, same, or separate database
 ... ...
 # Tachtler - MailZu # Tachtler - MailZu
Zeile 642: Zeile 645:
 // Allow users to view quarantined Viruses (Dangerous) // Allow users to view quarantined Viruses (Dangerous)
 // Virues are treated like Banned files and are placed  // Virues are treated like Banned files and are placed 
 +// in the Pending Requests and require Admin release
 +// $conf['app']['allowViruses'] = 0
 +$conf['app']['allowViruses'] = 0;
 +
 +// Allow users to search by Mailid
 +// $conf['app']['allowMailid'] = 0
 +$conf['app']['allowMailid'] = 0;
 +
 +include_once('init.php');
 +?>
 +</code>
 +
 +
 +Abschließend die **komplette Konfigurationsdatei**:
 +<code php>
 +<?php
 +/**
 +* This file sets all the configuration options
 +* All configuration options, such as colors,
 +*  text sizes, email addresses, etc.
 +*  are set in this file.
 +* @author Samuel Tran <stran2005@users.sourceforge.net>
 +* @author Brian Wong <bwsource@users.sourceforge.net>
 +* @author Jeremy Fowler <jfowler06@users.sourceforge.net>
 +* @version 04-03-07
 +* @package MailZu
 +*/
 +/***************************************
 +* MailZu                               *
 +* Version 0.8                          *
 +* http://www.mailzu.net                *
 +*                                      *
 +/***************************************/
 +/**
 +* Please refer to readme.html and LICENSE for any additional information
 +*
 +* Copyright (C) 2003 - 2007 MailZu
 +* This program is free software; you can redistribute it and/or modify it
 +* under the terms of the GNU General Public License as published by the
 +* Free Software Foundation; either version 2 of the License, or (at your option)
 +* any later version.
 +*
 +* This program is distributed in the hope that it will be useful, but WITHOUT
 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 +*
 +* You should have received a copy of the GNU General Public License along with
 +* this program; if not, write to the
 +* Free Software Foundation, Inc.
 +* 59 Temple Place
 +* Suite 330
 +* Boston, MA
 +* 02111-1307
 +* USA
 +*/
 +
 +/*************************************************/
 +/*                Instructions                   *
 +**************************************************
 +* + All words (string values) must               *
 +*  be enclosed in quotation marks                *
 +*  Numbers must not                              *
 +*                                                *
 +* + Default values are                           *
 +*  given in square brackets []                   *
 +/*************************************************/
 +
 +/**********
 +* Amavisd-new Settings
 +*
 +* The following settings must correspond to your amavisd-new setup
 +*
 +*
 +***********/
 +
 +// Amavisd-new AM.PDP port
 +// Since the port number can not be stored in the database
 +// all instances of amavisd-new must use the same AM.PDP port
 +$conf['amavisd']['spam_release_port'] = '9998';
 +
 +// Database type to be used by PEAR [mysql]
 +/* Options are:
 +        mysql  -> MySQL
 +        pgsql  -> PostgreSQL
 +        ibase  -> InterBase
 +        msql   -> Mini SQL
 +        mssql  -> Microsoft SQL Server
 +        oci8   -> Oracle 7/8/8i
 +        odbc   -> ODBC (Open Database Connectivity)
 +        sybase -> SyBase
 +        ifx    -> Informix
 +        fbsql  -> FrontBase
 +*/
 +$conf['db']['dbType'] = 'mysql';
 +
 +// Database user who can access the amavisd database
 +// Tachtler
 +// default: $conf['db']['dbUser'] = 'user';
 +$conf['db']['dbUser'] = 'amavis';
 +
 +// Password for above user to access the amavisd database
 +// Tachtler
 +// default: $conf['db']['dbPass'] = 'pass';
 +$conf['db']['dbPass'] = 'geheim';
 +
 +// Name of database
 +// Tachtler
 +// default: $conf['db']['dbName'] = 'dbname';
 +$conf['db']['dbName'] = 'amavis';
 +
 +// Database host specification (hostname[:port]) [localhost]
 +// Tachtler
 +// default: $conf['db']['hostSpec'] = 'hostname.example.com:3306';
 +$conf['db']['hostSpec'] = '192.168.0.30:3306';
 +
 +// If using the bytea or BLOB mail_text quarantine type set to
 +// True. Since amavisd-2.4.4.
 +// Tachtler
 +// default: $conf['db']['binquar'] = false;
 +$conf['db']['binquar'] = true;
 +
 +/**********
 +* Authentication Settings
 +*
 +* Choose your authentication method ($conf['auth']['serverType']),
 +* Then fill in the necessary auth information for corresponding method
 +*
 +***********/
 +// Available authentication methods
 +/* Options are:
 +        ldap -> Standard LDAP server, e.g. OpenLDAP
 +        ad   -> MS Active Directory
 +        sql  -> PHP PEAR compatible database
 +        exchange  -> MS Exchange 5.5
 +        imap  -> IMAP protocol
 +*/
 +// Tachtler
 +// default: $conf['auth']['serverType'] = 'ldap';
 +$conf['auth']['serverType'] = 'imap';
 +
 +
 +/*** LDAP Authentication Settings ***/
 +// List of LDAP servers
 +$conf['auth']['ldap_hosts'] = array( 'ldaphost.example.com' );
 +// if set to true, LDAP connection over SSL (PHP 4.0.4 minimum)
 +// if set to false or not set, unencrypted LDAP connection on port 389
 +$conf['auth']['ldap_ssl'] = false;
 +
 +// LDAP base dn, e.g. 'dc=example,dc=com'
 +$conf['auth']['ldap_basedn'] = 'dc=example,dc=org';
 +
 +// LDAP attribute used for the RDN to identify a person
 +// For instance if the DN for a given user is uid=joesmith,ou=people,dc=example,dc=com
 +// the attribute would be 'uid'
 +$conf['auth']['ldap_user_identifier'] = 'uid';
 +
 +// Container where all users are kept, e.g. 'ou=people'
 +// If you have users in multiple containers, leave this option blank.
 +// In this particular case you will need to allow anonymous binding
 +// or specify a search user/password to bind with
 +//$conf['auth']['ldap_user_container'] = 'ou=people';
 +$conf['auth']['ldap_user_container'] = '';
 +
 +// LDAP attribute used as login, e.g. 'uid', 'mail' or 'uidNumber'
 +$conf['auth']['ldap_login'] = 'uid';
 +
 +// LDAP attribute used as name for the welcome message, e.g. 'givenName', 'cn' or 'displayName'
 +$conf['auth']['ldap_name'] = 'givenName';
 +
 +// LDAP mail attribute(s) used as the final recipient address
 +// Could be the actual mail attribute or another attribute
 +// (in the latter case look for the "%m" token in the ldap query filter in amavisd.conf)
 +$conf['auth']['ldap_mailAttr'] = array('mailRoutingAddress');
 +
 +// If $conf['auth']['ldap_login'] is different from 'uid', we need to determine
 +// corresponding 'uid' by binding anonymously or with the user defined below.
 +// Leave blank for anonymous binding.
 +$conf['auth']['ldap_searchUser'] = '';
 +$conf['auth']['ldap_searchPassword'] = '';
 +
 +
 +/*** Active Directory Authentication Settings ***/
 +// List of AD Domain controllers
 +$conf['auth']['ad_hosts'] = array( 'dc1.example.com' );
 +// if set to true, LDAP connection over SSL (PHP 4.0.4 minimum)
 +// if set to false or not set, unencrypted LDAP connection on port 389
 +$conf['auth']['ad_ssl'] = false;
 +
 +// AD base dn, e.g. 'dc=example,dc=com'
 +$conf['auth']['ad_basedn'] = 'dc=example,dc=com';
 +
 +// AD domain, e.g. 'example.com'
 +$conf['auth']['ad_domain'] = 'example.com';
 +
 +// AD attribute used to identify a person
 +$conf['auth']['ad_user_identifier'] = 'samaccoutname';
 +
 +// AD attribute used as login, e.g. 'samaccountname' or 'mail'
 +$conf['auth']['ad_login'] = 'samaccountname';
 +
 +// AD attribute used as name for the welcome message, e.g. 'givenName', 'cn' or 'displayName'
 +$conf['auth']['ad_name'] = 'givenName';
 +
 +// AD mail attribute(s) used as the final recipient address
 +// Could be the actual mail attribute or another attribute
 +// (in the latter case look for the "%m" token in the ldap query filter in amavisd.conf)
 +// $conf['auth']['ad_mailAttr'] = array('mail'); // old
 +// For accounts with multiple email address aliases use proxyAddresses
 +$conf['auth']['ad_mailAttr'] = array('proxyAddresses');
 +
 +// If $conf['auth']['ad_login'] is different from 'samaccountname', we need to determine
 +// corresponding 'samaccountname' by binding with the user defined below.
 +// Ad does not support anonymous bind
 +$conf['auth']['ad_searchUser'] = 'manager';
 +$conf['auth']['ad_searchPassword'] = 'secret';
 +
 +
 +/*** Database Authentication Settings ***/
 +// Database type to be used by PEAR
 +/* Options are:
 +        mysql  -> MySQL
 +        pgsql  -> PostgreSQL
 +        ibase  -> InterBase
 +        msql   -> Mini SQL
 +        mssql  -> Microsoft SQL Server
 +        oci8   -> Oracle 7/8/8i
 +        odbc   -> ODBC (Open Database Connectivity)
 +        sybase -> SyBase
 +        ifx    -> Informix
 +        fbsql  -> FrontBase
 +*/
 +$conf['auth']['dbType'] = 'mysql';
 +
 +// Database host specification (hostname[:port]) [localhost]
 +$conf['auth']['dbHostSpec'] = '';
 +
 +// Database user who can access the auth database
 +$conf['auth']['dbUser'] = '';
 +
 +// Password for above user to auth database
 +$conf['auth']['dbPass'] = '';
 +
 +// Name for auth database
 +$conf['auth']['dbName'] = '';
 +
 +// Name for auth table that contains usernames and passwords
 +$conf['auth']['dbTable'] = '';
 +
 +// Name of the Username field of the SQL table
 +$conf['auth']['dbTableUsername'] = '';
 +
 +// Name of the password field of the SQL table
 +$conf['auth']['dbTablePassword'] = '';
 +
 +// Name of the 'first name' or 'full name' field of the SQL table
 +// This is used for the welcome message
 +// If such a field does not exist, leave it blank
 +$conf['auth']['dbTableName'] = '';
 +
 +// Name of the 'mail address' field of the SQL table
 +$conf['auth']['dbTableMail'] = '';
 +
 +// Hash configuration
 +// true   = passwords are md5 encrypted in database
 +// false  = passwords are cleartext in database
 +$conf['auth']['dbIsMd5'] = true;
 +
 +
 +/*** Exchange 5.5 Authentication Settings ***/
 +// Exchange 5.5 server host and IMAP port (e.g.: 10.1.1.20:143)
 +$conf['auth']['exch_host'] = '';
 +
 +// Exchange's LDAP server, it usually has the same IP as the Exchange server (e.g.: ldap://10.1.1.20)
 +$conf['auth']['exch_ldap'] = '';
 +
 +// Exchange default NT domain
 +$conf['auth']['exch_domain'] = '';
 +
 +
 +/*** IMAP Authentication Settings ***/
 +// List of IMAP servers and ports (e.g.: 10.1.1.20:143)
 +// Tachtler
 +// default: $conf['auth']['imap_hosts'] = array( 'imaphost.example.com:143' );
 +$conf['auth']['imap_hosts'] = array( '192.168.0.80:143' );
 +
 +// IMAP type
 +/* Options are:
 +        imap     -> default
 +        imaptls  -> do not do start-TLS to encrypt the session, even with servers that support it
 +        imapssl  -> use the Secure Socket Layer to encrypt the session
 +        imapcert -> use the Secure Socket Layer to encrypt the session,
 +                    do not validate certificates from TLS/SSL server, needed if server uses self-signed certificates
 +*/
 +// Tachtler
 +// $conf['auth']['imap_type'] = 'imapssl';
 +$conf['auth']['imap_type'] = 'imaptls';
 +
 +// Domain name part of the email address, (e.g.: example.com)
 +// Tachtler
 +// default: $conf['auth']['imap_domain_name'] = 'example.com';
 +$conf['auth']['imap_domain_name'] = 'tachtler.net';
 +
 +
 +/**
 +* End of Authentication Settings
 +*/
 +
 +/*** Permission listings ****/
 +/* The items you put in the admin lists
 +*  must be the same as the login ID.
 +*  Example:
 +*  If you login as 'userid' then..
 +*  conf['auth']['s_admins'] = array ('userid','userid2');
 +*
 +*  OR
 +*
 +*  If you login as 'userid@example.com' then...
 +*  conf['auth']['s_admins'] = array ('userid@example.com',
 +*                                    'userid2@example.com'
 +*                                   );
 +*
 +*/
 +
 +// List of Super Admins
 +// Super Admins can do anything mail admins can plus
 +// change settings
 +// Tachtler
 +// default: $conf['auth']['s_admins'] = array ('user1', 'user2');
 +$conf['auth']['s_admins'] = array ('admin');
 +
 +// List of Mail Admins
 +// Mail Admins can see other users' spam and attachments
 +// and can perform any action on them
 +// Tachtler
 +// default: $conf['auth']['m_admins'] = array ();
 +$conf['auth']['m_admins'] = array ('admin');
 +
 +// User login restriction (Does not affect admins)
 +// If set to true, users will not be able to login. This is if you do
 +// not want users to view their quarantine, yet only have admins to
 +// view quarantines.
 +$conf['auth']['login_restriction'] = false;
 +
 +// User restriction exemption
 +// List of users still allowed to login even if
 +// $conf['auth']['login_restriction'] = true
 +//
 +// Tachtler
 +// default: $conf['auth']['restricted_users'] = array('user1', 'user2');
 +$conf['auth']['restricted_users'] = array('klaus');
 +
 +/**********
 +* Miscellaneous Settings
 +*
 +* The following settings must correspond to your amavisd-new setup
 +*
 +***********/
 +
 +// Image to appear at the top of each page ['img/mailzu.gif']
 +// Leave this string empty if you are not going to use an image
 +// Specifiy link as 'directory/filename.gif'
 +$conf['ui']['logoImage'] = 'img/mailzu.gif';
 +
 +// Welcome message show at login page ['Welcome to MailZu!']
 +$conf['ui']['welcome'] = 'Welcome to MailZu!';
 +
 +// The full url to the root directory of MailZu
 +// Please do not include the trailing slash
 +// Tachtler
 +// $conf['app']['weburi'] = 'https://mailzuhost.example.com/mailzu';
 +$conf['app']['weburi'] = 'https://mailzu.tachtler.net/';
 +
 +// How to send email ['mail']
 +/* Options are:
 +        'mail' for PHP default mail
 +        'smtp' for SMTP
 +        'sendmail' for sendmail
 +        'qmail' for qmail MTA
 +*/
 +// Tachtler
 +// default: $conf['app']['emailType'] = 'mail';
 +$conf['app']['emailType'] = 'smtp';
 +
 +// SMTP email host address []
 +// This is only required if emailType is SMTP
 +// Tachtler
 +// default: $conf['app']['smtpHost'] = '';
 +$conf['app']['smtpHost'] = 'mx1.tachtler.net';
 +
 +// SMTP port [25]
 +// This is only required if emailType is SMTP
 +$conf['app']['smtpPort'] = 25;
 +
 +// Path to sendmail ['/usr/sbin/sendmail']
 +// This only needs to be set if the emailType is 'sendmail'
 +$conf['app']['sendmailPath'] = '/usr/sbin/sendmail';
 +
 +// Path to qmail ['/var/qmail/bin/sendmail']
 +// This only needs to be set if the emailType is 'qmail'
 +$conf['app']['qmailPath'] = '/var/qmail/bin/sendmail';
 +
 +// Support for recipient delimiters
 +// Enter the character used as a delimiter for your site
 +// or leave empty
 +// $conf['recipient_delimiter'] = '+';
 +// Tachtler
 +// default: $conf['recipient_delimiter'] = '';
 +$conf['recipient_delimiter'] = '+';
 +
 +// The email addresses of the support staff and/or administrator
 +// An email is sent to these addresses when a user reports an error
 +// or clicks the "Email Administrator" link
 +// Tachtler
 +// default: $conf['app']['adminEmail'] = array('support@example.com');
 +$conf['app']['adminEmail'] = array('postmaster@tachtler.net');
 +
 +// Email admin upon Release Request
 +// When users try to release a banned file a request is sent to an
 +// admin. Admins can always look at 'Pending Requests' in the MailZu
 +// interface regardless.
 +//
 +// $conf['app']['notifyAdmin'] = 1;
 +// Tachtler
 +// default: $conf['app']['notifyAdmin'] = 0;
 +$conf['app']['notifyAdmin'] = 1;
 +
 +// Show the "Email Administrator" link for users
 +// If you have a large userbase, you may not want users to have the
 +// capability to just email the admin
 +// Note: The "Report Error" link is still available regardless
 +// of this option. This link is only visible if a fatal error occurs
 +// with releasing attachments. Default is 1 (show link).
 +//
 +// $conf['app']['showEmailAdmin'] = 0;
 +$conf['app']['showEmailAdmin'] = 1;
 +
 +// Site Quarantine Summary display toggle.
 +// Enable and display the "Site Quarantine Summary" link for admins.
 +// Viewing the site summary may be an expensive database query.
 +// Large sites may want to turn this off.
 +// $conf['app']['siteSummary'] = 1
 +$conf['app']['siteSummary'] = 1;
 +
 +// Show Site Quarantine in search only mode if set to 1.
 +// No message is displayed when clicking on 'Site quarantine'.
 +// Keep the default for for large sites.
 +// $conf['app']['searchOnly'] = 1
 +// Tachtler
 +// $conf['app']['searchOnly'] = 1;
 +$conf['app']['searchOnly'] = 0;
 +
 +// The default language code.  This must be included in the language list in
 +// langs.php
 +// Tachtler
 +// $conf['app']['defaultLanguage'] = 'en_US';
 +$conf['app']['defaultLanguage'] = 'de';
 +
 +// Display the choice for language selection during the login screen if set to 1
 +// Otherwise set it to 0
 +// Default is 1
 +$conf['app']['selectLanguage'] = '1';
 +
 +// If you are running PHP in safe mode, set this value to 1.
 +// This toggles if we use the included Pear DB and Mail_Mime libraries included
 +// with this distribution
 +$conf['app']['safeMode'] = 0;
 +
 +// View time in 12 or 24 hour format [12]
 +// Only acceptable values are 12 and 24 (if an invalid number is set, 12 hour
 +// time will be used)
 +// Tachtler
 +// default: $conf['app']['timeFormat'] = 12;
 +$conf['app']['timeFormat'] = 24;
 +
 +// Title of application ['MailZu']
 +// Will be used for page titles and in 'From' field of email responses
 +$conf['app']['title'] = 'MailZu';
 +
 +// If we should log system activity or not [0]
 +// Can be 0 (for no) and 1 (for yes)
 +$conf['app']['use_log'] = 1;
 +
 +// If we should log additional debug information
 +$conf['app']['debug'] = 0;
 +
 +// Directory/file for log ['/var/log/mailzu.log']
 +// Specify as /directory/filename.extension
 +$conf['app']['logfile'] = '/var/log/mailzu.log';
 +
 +// Maximum number of messages displayed per page
 +// Tachtler
 +// default: $conf['app']['displaySizeLimit'] = 50;
 +$conf['app']['displaySizeLimit'] = 25;
 +
 +// Allow users to view quarantined Bad Header messages
 +// Bad headers are treated like spam and released
 +// $conf['app']['allowBadHeaders'] = 0
 +$conf['app']['allowBadHeaders'] = 0;
 +
 +// Allow users to view quarantined Viruses (Dangerous)
 +// Virues are treated like Banned files and are placed
 // in the Pending Requests and require Admin release // in the Pending Requests and require Admin release
 // $conf['app']['allowViruses'] = 0 // $conf['app']['allowViruses'] = 0
Zeile 670: Zeile 1174:
 gekennzeichnet sind: gekennzeichnet sind:
  
-Hier de notwendigen Konfigurationen von **''/var/www/html/mailzu/scripts/mz_db_clean.pl''** (**nur relevanter Ausschnitt**):+Hier de notwendigen Konfigurationen von **''/var/www/html/mailzu/scripts/mz_db_clean.pl''** (**komplettes Konfigurations-Skript**):
 <code perl> <code perl>
 #!/usr/bin/perl -w #!/usr/bin/perl -w
-# Tachtler 
-# default: #!/usr/local/bin/perl -w 
  
 use strict; use strict;
Zeile 692: Zeile 1194:
         'amavis','geheim'         'amavis','geheim'
                        );                        );
- 
  
 # Set this to 1 if you are using the new database schema # Set this to 1 if you are using the new database schema
Zeile 698: Zeile 1199:
 # have the foreign key references between the tables and use # have the foreign key references between the tables and use
 # time_iso as a real date type instead of a string. # time_iso as a real date type instead of a string.
 +# Tachtler
 +# default: my($new_dd) = 1; # 1 or undef
 my($new_dd) = undef; # 1 or undef my($new_dd) = undef; # 1 or undef
  
Zeile 717: Zeile 1220:
 # MySQL # MySQL
 # Tachtler # Tachtler
 +# default: #my($new_interval) = '7 day';
 +# default: #my($new_partial_interval) = '1 hour';
 my($new_interval) = '7 day'; my($new_interval) = '7 day';
 my($new_partial_interval) = '1 hour'; my($new_partial_interval) = '1 hour';
Zeile 726: Zeile 1231:
  
 ##### END OF CONFIGURATION SECTION ###### ##### END OF CONFIGURATION SECTION ######
-... 
-</code> 
  
-Der Aufruf des Scriptswelches ein Perl-Script istmuss mit einem Parameter für die Angabe des Datenbank-Typshier [[http://www.mysql.de/|MySQL]] erfolgenwas auch eine Abfrage wie nachfolgend dargestellt zeigt+# Options array 
-<code+my(%opt); 
-/var/www/html/mailzu/scripts/mz_db_clean.pl -h + 
-Usage: +my(@modules); 
-        mz_db_clean.pl [--verbose|-v] [--database|-db <dbtype>+my(@missing); 
-        mz_db_clean.pl --help|-h + 
 +my(@dsn) = split(/:/,$storage_sql_dsn[0],-1); 
 +push(@modules'DBD::'.$dsn[1])  if uc($dsn[0]) eq 'DBI'; 
 + 
 +for my $m (@modules) { 
 +  local($_) = $m; 
 +  $_ .= /^auto::/ ? '.al' : '.pm'  if !/\.(pm|pl|al)\z/; 
 +  s[::][/]g; 
 +  eval { require $_ } or push(@missing$m); 
 +
 + 
 +die "ERRORMISSING module(s):\n" . join('', map { "  $_\n" } @missing) if @missing; 
 + 
 +sub build_queries($) { 
 +  my($dbtype) = shift; 
 +  # Return a hash of queries to be run 
 +  my(%query) = ( 
 +               # Old schema queries 
 +               'del_d_flag' => 
 +                 'DELETE FROM msgrcpt ' . 
 +                 'WHERE rs=\'D\'', 
 +               'del_partial_msg' => 
 +                 'DELETE FROM msgs ' . 
 +                 "WHERE time_num $partial_interval " . 
 +                 'AND content IS NULL', 
 +               'del_old_mail_ids' =
 +                 'DELETE FROM msgs ' . 
 +                 "WHERE time_num < $interval", 
 +               'del_msgs_mail_ids' => 
 +                 'DELETE FROM msgs ' . 
 +                 'WHERE NOT EXISTS ' . 
 +                 ' (SELECT 1 FROM msgrcpt ' . 
 +                 '  WHERE msgrcpt.mail_id=msgs.mail_id)', 
 +               'del_quarantine' => 
 +                 'DELETE FROM quarantine ' . 
 +                 'WHERE NOT EXISTS '. 
 +                 ' (SELECT 1 FROM msgs ' . 
 +                 '  WHERE msgs.mail_id=quarantine.mail_id)', 
 +               'del_msgrcpt' => 
 +                 'DELETE FROM msgrcpt ' . 
 +                 'WHERE NOT EXISTS ' . 
 +                 ' (SELECT 1 FROM msgs ' . 
 +                 '  WHERE msgs.mail_id=msgrcpt.mail_id)', 
 + 
 +               New schema queries 
 +               'del_d_flag_new' => 
 +                 'DELETE FROM msgs ' . 
 +                 'WHERE mail_id IN ' . 
 +                 '  (SELECT DISTINCT mail_id ' . 
 +                 '   FROM msgrcpt WHERE rs=\'D\')', 
 + 
 +               # Generic queries 
 +               'del_maddr' => 
 +                 'DELETE FROM maddr ' . 
 +                 'WHERE NOT EXISTS ' 
 +                 '  (SELECT sid FROM msgs WHERE sid=id) ' . 
 +                 '   AND NOT EXISTS'
 +                 '  (SELECT rid FROM msgrcpt WHERE rid=id)' 
 + 
 +             ); 
 + 
 +  if ($dbtype eq 'pgsql') { 
 +    $query{'vacuum_analyze'} = 'VACUUM ANALYZE'; 
 +    # New schema queries 
 +    $query{'del_old_mail_ids_new'} = 'DELETE FROM msgs ' . 
 +                                     'WHERE time_iso < now() ' . 
 +                                     "interval '$new_interval'"; 
 +    $query{'del_partial_msg_new'} = 'DELETE FROM msgs ' . 
 +                                     'WHERE time_iso < now() ' . 
 +                                     "- interval '$new_partial_interval' " . 
 +                                     ' AND content IS NULL'; 
 +  } 
 + 
 +  if ($dbtype eq 'mysql') { 
 +    # New schema queries 
 +    $query{'del_old_mail_ids_new'} = 'DELETE FROM msgs ' . 
 +                                     'WHERE time_iso < UTC_TIMESTAMP() ' . 
 +                                     "- interval $new_interval"; 
 +    $query{'del_partial_msg_new'} = 'DELETE FROM msgs ' . 
 +                                     'WHERE time_iso < UTC_TIMESTAMP() ' . 
 +                                     "- interval $new_partial_interval " . 
 +                                     ' AND content IS NULL'; 
 + 
 +    # Old schema queries 
 +    $query{'del_msgs_mail_ids'} = 'DELETE msgs FROM msgs ' . 
 +                                  'LEFT JOIN msgrcpt USING(mail_id) ' . 
 +                                  'WHERE msgrcpt.mail_id IS NULL'; 
 +    $query{'del_quarantine'} = 'DELETE quarantine FROM quarantine ' . 
 +                               'LEFT JOIN msgs USING(mail_id) '. 
 +                               'WHERE msgs.mail_id IS NULL'; 
 +    $query{'del_msgrcpt'} = 'DELETE msgrcpt FROM msgrcpt ' . 
 +                            'LEFT JOIN msgs USING(mail_id) ' . 
 +                            'WHERE msgs.mail_id IS NULL'; 
 +  } 
 + 
 +  my(%post_query) = ( 
 +                'vacuum_analyze' => 'VACUUM ANALYZE' 
 +                    ); 
 + 
 +  # Order of execution IS IMPORTANT! 
 +  my(@query_order) = qw (del_d_flag del_partial_msg del_msgs_mail_ids 
 +                         del_old_mail_ids del_quarantine del_msgrcpt 
 +                         del_maddr 
 +                        ); 
 + 
 +  @query_order = qw (del_d_flag_new del_partial_msg_new 
 +                         del_old_mail_ids_new del_maddr 
 +                        ) if $new_dd; 
 + 
 +  my(@post_query_order); 
 +  push(@post_query_order, 'vacuum_analyze') if $dbtype eq 'pgsql' && $postop_vacuum; 
 + 
 +  return (\%query,\@query_order,\%post_query,\@post_query_order); 
 +
 + 
 + 
 +sub usage { 
 +  print "Usage:\n"; 
 +  print "\tmz_db_clean.pl [--verbose|-v] [--database|-db <dbtype>]\n"; 
 +  print "\tmz_db_clean.pl --help|-h \n\n"; 
 +  print "\tThe database configuration parameter is REQUIRED!\n\n"; 
 +  print "\tPossible parameters for the \'--database\' option is \'mysql\'\n"
 +        "\tand 'pgsql'.\n"; 
 +  exit; 
 +
 + 
 +sub main { 
 +  Getopt::Long::Configure('no_ignore_case'); 
 +  GetOptions(\%opt, 'help|h', 'database|db=s', 'verbose|v', 
 +            ) or exit(1); 
 +  usage if $opt{help}; 
 +  usage if not $opt{database}; 
 +  my($dbh) = connect_to_sql(@storage_sql_dsn); 
 +  my($query,$query_order,$p_query,$p_query_order) = build_queries($opt{database}); 
 +  my($sth_ref) = prepare_queries($dbh,$query,$p_query); 
 +  my($result) = exec_queries($dbh,$sth_ref,$query,$p_query, 
 +                             $query_order,$p_query_order 
 +                            ); 
 +  print "Database cleanup successful\n" if $result; 
 +  $dbh->disconnect; 
 +
 + 
 +sub exec_queries($$$$$) { 
 +  my($dbh,$sth_ref,$query,$p_query,$query_o,$p_query_o) = @_; 
 +  my($affected); 
 + 
 +  $dbh->begin_work; 
 +  eval { 
 +    foreach (@$query_o) { 
 +      if ($opt{verbose}) { 
 +        print "Executing... " . localtime() . "\n"; 
 +        print $query->{$_} . "\n"; 
 +      } 
 +      $affected = $sth_ref->{$_}->execute or die "Query '$_' did not execute"; 
 +      print "$affected rows affected\n" if $opt{verbose}; 
 +    } 
 +  }; 
 +  if ($@ ne '') { 
 +    $dbh->rollback; 
 +    print "There was an error executing a query! $@\n" . 
 +          "No records modified by database maintenance\n"
 +          "Rollback complete.\n"; 
 +    return undef 
 +  } else { 
 +    $dbh->commit; 
 +  } 
 + 
 +  eval { 
 +    foreach (@$p_query_o) { 
 +      if ($opt{verbose}) { 
 +        print "Executing... " . localtime() . "\n"; 
 +        print $p_query->{$_} . "\n"; 
 +      } 
 +      $affected = $sth_ref->{$_}->execute or die "Query '$_' did not execute"; 
 +      print "$affected rows affected\n" if $opt{verbose}; 
 +    } 
 +  }; 
 +  if ($@ ne '') { 
 +    print "There was an error executing an optional query! $@\n" . 
 +    return undef 
 +  } 
 + 
 +  return 1; 
 + 
 +
 + 
 +sub connect_to_sql(@) { 
 +  my(@sql_dsn) = @_; 
 +  my($dsn, $username, $password) = @sql_dsn; 
 +  print "Connecting to SQL database server\n" if $opt{verbose}; 
 +  print "Trying dsn '$dsn'\n" if $opt{verbose}; 
 +  my($dbh) = DBI->connect($dsn, $username, $password, 
 +#     {PrintError => 1, RaiseError => 0, Taint => 1, AutoCommit => 0} ); 
 +     {PrintError => 1, RaiseError => 0, Taint => 1} ); 
 +  if ($dbh) { 
 +    print "Connection to '$dsn' succeeded\n" if $opt{verbose}; 
 +  } else { 
 +    die "Unable to connect to '$dsn'!\n"; 
 +  } 
 +  $dbh; 
 +}
  
-        The database configuration parameter is REQUIRED!+sub prepare_queries($$$) { 
 +  my($dbh) = shift; 
 +  my($query) = shift; 
 +  my($p_query) = shift; 
 +  my(%sths); 
 +  foreach my $query_set ($query, $p_query) { 
 +    foreach (keys %$query) { 
 +      $sths{$_} = $dbh->prepare($query->{$_}); 
 +    } 
 +  } 
 +  \%sths 
 +}
  
-        Possible parameters for the '--database' option is 'mysql' +main;
-        and 'pgsql'.+
 </code> </code>
  
Zeile 775: Zeile 1488:
 ===== Postfix AMaViS MailZu deutsche Sprachdatei ===== ===== Postfix AMaViS MailZu deutsche Sprachdatei =====
  
-Unter nachfolgenden Link auf mein Repository --> [[http://www.repository.tachtler.net/mailzu/|http://www.repository.tachtler.net/mailzu]] können die entsprechenden deutschen Sprachdateien +Unter nachfolgenden Link auf mein Repository --> [[http://www.repository.tachtler.net/applications/mailzu/|http://www.repository.tachtler.net/applications/mailzu/]] können die entsprechenden deutschen Sprachdateien 
   * **''de.help.php''**   * **''de.help.php''**
   * **''de.lang.php''**   * **''de.lang.php''**
Zeile 824: Zeile 1537:
 ===== Postfix AMaViS MailZu Patch 2.7.0 ===== ===== Postfix AMaViS MailZu Patch 2.7.0 =====
  
-Ab der Version +**Ab der [[http://www.ijs.si/software/amavisd/|AMaViS]] Version 2.7.0** ist nachfolgende Programmdatei von [[http://sourceforge.net/projects/mailzu/|MailZu]] zu "patchen", da sonst **Fehler beim Zugriff auf die Datenbank** auftauchen. 
 + 
 +Die Datei, welche "gepatched" werden muss lautet 
 +  * **''/var/www/mailzu/lib/DBEngine.class.php''** 
 + 
 +Der **"Patch"** mit dem Namen **''Amavisd-new 2.7.0 compatibility''** kann unter nachfolgendem Link 
 +heruntergeladen werden: 
 +  * **[[http://sourceforge.net/tracker/?func=detail&aid=3365667&group_id=137277&atid=738236|Amavisd-new 2.7.0 compatibility]]** 
 + 
 +:!: **HINWEIS** - **In nachfolgende Datei, wurde von mir der oben genannte "Patch" bereits eingearbeitet!** 
 + 
 +  * **{{:tachtler:mailzu:dbengine.class.php_amavis_2.7.0_patch.zip|DBEngine.class.php_AMaViS_2.7.0_Patch.zip}}**
  
 ===== Postfix AMaViS MailZu Fehlerbehebung ===== ===== Postfix AMaViS MailZu Fehlerbehebung =====
Zeile 847: Zeile 1571:
   // Tachtler   // Tachtler
   $content_type='';   $content_type='';
 +</code>
 +
 +==== mail_id mit '_' ====
 +
 +Seitdem Postfix auch e-Mail-ID's mit dem Zeichen ''_'' (**Unterstrich**) vergibt, kann es beim z.B. löschen von e-Mails aus der Quarantäne Anzeige von [[http://sourceforge.net/projects/mailzu/|MailZu]] zu Problemen kommen.
 +
 +:!: **HINWEIS** Nachfolgende Code-Zeilen lösen dieses Problem!
 +
 +Die Programmdatei von [[http://sourceforge.net/projects/mailzu/|MailZu]] mit nachfolgendem Namen **__muss__** wie folgt beschrieben angepasst werden:
 +  * **''lib/Quarantine.lib.php''**
 +Die Veränderungen sind **ab Zeile 260** durchzuführen:
 +
 +**Vorher** (nur relevanter Ausschnitt):
 +<code>
 +...
 +                        // Get mail_id and recipient email address
 +                        $temp = preg_split('/_/', $mail_id_recip, 2);
 +                        $mail_id = $temp[0];
 +                        $recip_email = $temp[1];
 +...
 +</code>
 +
 +**Nachher** (nur relevanter Ausschnitt):
 +<code>
 +...
 +                        // Get mail_id and recipient email address
 +                        // Tachtler
 +                        // default: $temp = preg_split('/_/', $mail_id_recip, 2);
 +                        // default: $mail_id = $temp[0];
 +                        // default: $recip_email = $temp[1];
 +                        $help_recip_email = array_reverse(explode('_', $mail_id_recip));
 +                        $recip_email = $help_recip_email[0];
 +                        $help_mail_id = explode('_' . $recip_email, $mail_id_recip);
 +                        $mail_id = $help_mail_id[0];
 +...
 </code> </code>
  
tachtler/postfix_amavis_mailzu_installieren.1363941143.txt.gz · Zuletzt geändert: 2013/03/22 09:32 von klaus