IRedMail/FAQ/Integrate.MySQL.in.Amavisd
From iRedMail
(Difference between revisions)
(→Steps) |
|||
| (4 intermediate revisions not shown) | |||
| Line 1: | Line 1: | ||
__TOC__ | __TOC__ | ||
| - | Note: This | + | Note: This integration will be available in iRedMail-0.7.0 and later versions. |
= Summary = | = Summary = | ||
| Line 15: | Line 15: | ||
* Create necessary database and import SQL structure template file: | * Create necessary database and import SQL structure template file: | ||
| + | ** '''WARNING''': Please replace 'secret_passwd' below with your own password. | ||
{{cmd|<pre> | {{cmd|<pre> | ||
$ mysql -uroot -p | $ mysql -uroot -p | ||
| Line 25: | Line 26: | ||
* Configure Amavisd in /etc/amavisd.conf (RHEL/CentOS) or /etc/amavis/conf.d/50-user (Debian/Ubuntu) or /usr/local/etc/amavisd.conf (FreeBSD): | * 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. | ||
{{cmd|<pre> | {{cmd|<pre> | ||
| - | @ | + | @storage_sql_dsn = ( |
['DBI:mysql:database=amavisd;host=localhost;port=3306', 'amavisd', 'secret_passwd'], | ['DBI:mysql:database=amavisd;host=localhost;port=3306', 'amavisd', 'secret_passwd'], | ||
); | ); | ||
| - | |||
$sql_allow_8bit_address = 1; | $sql_allow_8bit_address = 1; | ||
</pre>}} | </pre>}} | ||
| - | * 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/ | + | * 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): |
{{cfg|/usr/sbin/amavisd|<pre> | {{cfg|/usr/sbin/amavisd|<pre> | ||
$dbh->do("SET NAMES utf8"); # <-- Add this line. | $dbh->do("SET NAMES utf8"); # <-- Add this line. | ||
Current revision as of 08:34, 20 April 2011
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.
