IRedMail/FAQ/Integrate.MySQL.in.Amavisd

From iRedMail
Jump to: navigation, search

Contents


Note: This integration will be available in iRedMail-0.7.0 and later versions.

Summary

With MySQL integration, Amavisd can lookup per-user whitelist/blacklist and other policies from MySQL, and store incoming & outgoing email information in MySQL For example, mail size, sender/recipient, subject.

Steps

  • Download SQL structure template file. This template file is extracted from Amavisd doc file: docs/README.sql-mysql.
Terminal:
$ cd /tmp/
$ wget http://iredmail.googlecode.com/hg/iRedMail/samples/amavisd.mysql
  • Create necessary database and import SQL structure template file:
    • WARNING: Please replace 'secret_passwd' below with your own password.
Terminal:
$ mysql -uroot -p
mysql> CREATE DATABASE amavisd DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON amavisd.* TO "amavisd"@localhost IDENTIFIED BY 'secret_passwd';
mysql> USE amavisd;
mysql> SOURCE /tmp/amavisd.mysql;
mysql> FLUSH PRIVILEGES;
  • Configure Amavisd in /etc/amavisd.conf (RHEL/CentOS) or /etc/amavis/conf.d/50-user (Debian/Ubuntu) or /usr/local/etc/amavisd.conf (FreeBSD):
    • WARNING: Please replace 'secret_passwd' below with your own password.
Terminal:
@storage_sql_dsn = (
    ['DBI:mysql:database=amavisd;host=localhost;port=3306', 'amavisd', 'secret_passwd'],
);
$sql_allow_8bit_address = 1;
  • In Amavisd-new-2.6.4 and older versions, it can't store mail subject as "UTF-8" characters, you can fix it by edit /usr/sbin/amavisd (RHEL/CenTOS/OpenSuSE, near line 19412) or /usr/sbin/amavisd-new (DEBIAN/UBUNTU, near line 18126) or /usr/local/sbin/amavisd (FreeBSD):
File: /usr/sbin/amavisd
  $dbh->do("SET NAMES utf8");          # <-- Add this line.
  section_time('sql-connect');
  • Restart amavisd service.
Personal tools