Linux Courier IMAP + MySQL Setup HOWTO
MySQL Configuration
create database maildb;
grant select,insert,update,delete on maildb.* to mail@localhost identified by 'secret';
flush privileges;
use maildb;
CREATE TABLE users (
id char(128) DEFAULT
NOT NULL,
crypt char(128) DEFAULT
NOT NULL,
clear char(128) DEFAULT
NOT NULL,
name char(128) DEFAULT
NOT NULL,
uid int(10) unsigned DEFAULT '65534' NOT NULL,
gid int(10) unsigned DEFAULT '65534' NOT NULL,
home char(255) DEFAULT
NOT NULL,
maildir char(255) DEFAULT
NOT NULL,
quota char(255) DEFAULT
NOT NULL,
KEY id (id(128))
);
CREATE TABLE domains (
userid char(128) NOT NULL default
,
KEY userid (userid)
);
INSERT INTO domains (userid) VALUES ("compute.info");
INSERT INTO users (id, crypt, clear, name, home, maildir) VALUES (
"spam@compute.info", "jnk.l3QByZvdk", "lrepsak", "Kasperl",
"/home/spam/",
"/home/spam/Maildir/");
Crypt password can be generated by the following script
#!/usr/bin/perl
if( $#ARGV != 0 )
{
print "usage: vcrypt password\n";
exit 1;
}
my $salt = join
, ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64];
print crypt($ARGV[0], $salt) ."\n";
/etc/courier/authdaemonrc
authmodulelist="authmysql"
#authmodulelist="authpam authpwd authshadow"
/etc/courier/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME mail
MYSQL_PASSWORD secret
MYSQL_DATABASE maildb
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD crypt
MYSQL_LOGIN_FIELD id
MYSQL_HOME_FIELD home
MYSQL_NAME_FIELD name