This website is not maintained anymore. Please visit www.nerdgirl.dkinstead  
This page was last modified: July 27 2010 13:22:12   
Too Cool for Internet Explorer

Mail setup tutorial - Preparations

  1. Preparations
  2. Courier IMAP
  3. Cyrus SASL2
  4. Postfix
  5. Testing and startup
  6. Setting up TLS
  7. Squirrelmail
  8. Spamassassin
Previous Current Next
  Preparations Courier IMAP >>

The Database

This mail setup is based on having all mail users and there settings saved in mysql tables. If MySQL is not installed yet, please do so and return to this page when you are done.

The following queries will create the postfix database and the database users 'postfix'.

Instead of the command prompt, you may want to use phpMyAdmin for this.:

password should be replaced with a password of your choice

CREATE DATABASE postfix;

GRANT USAGE ON * . * TO 'postfix'@'localhost' IDENTIFIED BY 'password' 
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;
GRANT SELECT , INSERT , UPDATE , DELETE ON `postfix` . * TO 'postfix'@'localhost';

FLUSH PRIVILEGES;

You are now ready to create the tables for your virtual users

USE postfix;

CREATE TABLE alias (
 address varchar(255) NOT NULL default '',
 goto text NOT NULL,
 domain varchar(255) NOT NULL default '',
 created datetime NOT NULL default '0000-00-00 00:00:00',
 modified datetime NOT NULL default '0000-00-00 00:00:00',
 active tinyint(4) NOT NULL default '1',
 PRIMARY KEY (address),
 KEY address (address)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Aliases';


CREATE TABLE domain (
 domain varchar(255) NOT NULL default '',
 description varchar(255) NOT NULL default '',
 aliases int(10) NOT NULL default '-1',
 mailboxes int(10) NOT NULL default '-1',
 maxquota int(10) NOT NULL default '-1',
 created datetime NOT NULL default '0000-00-00 00:00:00',
 modified datetime NOT NULL default '0000-00-00 00:00:00',
 active tinyint(4) NOT NULL default '1',
 PRIMARY KEY (domain),
 KEY domain (domain)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Domains';


CREATE TABLE mailbox (
 username varchar(255) NOT NULL default '',
 password varchar(255) NOT NULL default '',
 name varchar(255) NOT NULL default '',
 maildir varchar(255) NOT NULL default '',
 quota int(10) NOT NULL default '-1',
 domain varchar(255) NOT NULL default '',
 created datetime NOT NULL default '0000-00-00 00:00:00',
 modified datetime NOT NULL default '0000-00-00 00:00:00',
 active tinyint(4) NOT NULL default '1',
 PRIMARY KEY (username),
 KEY username (username)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Mailboxes';

Heres an example of how to use the above tables:

The table 'domain', contains the domains hosted on your server:

INSERT INTO domain (domain,description) VALUES ('domain.tld','Description of your choice');

The following creates a mailuser belonging to the above domain.

Use your shell prompt to create an encrypted password for the user. Replace password and saltsalt with values of your own choice. (saltsalt must consist of exactly 8 characters).

perl -e 'print crypt $ARGV[0], "\$1\$$ARGV[1]"' password saltsalt
$1$saltsalt$qjXMvbEw8oaL.CzflDtaK/

The 34 characters returned, is the encrypted password, which you'll use when creating the mailuser in the 'postfix' database:

INSERT INTO mailbox (username,password,name,maildir)
VALUES ('postmaster@domain.tld','$1$saltsalt$qjXMvbEw8oaL.CzflDtaK/',
'Postmaster','postmaster@domain.tld/');

You are now ready to proceed to the next step, that is installing Courier-IMAP. Click the link below 'Next'.

Previous Current Next
  Preparations Courier IMAP >>