SmatrCGI Logo
  
Home News Products Customers Contact us
     
Web Development

About
Portfolio
Prices
Contact us

Web Design

About
Portfolio
Prices
Contact us

Translating

About
Languages
Prices
Contact us


Documentation - Postfix HOWTO - description

Postfix installation HOWTO


MySQL installation

Download and install one of the last versions of mysql server that you can take at http://www.mysql.com. After installing create a database named 'postfix', a user 'postfix' and give access to this user. At our example we use password 'test123'.
    
    mysql> create database postfix;
    Query OK, 1 row affected (0.01 sec)

    mysql> grant ALL PRIVILEGES ON postfix.* TO postfix@localhost IDENTIFIED by 'pass123';
    Query OK, 0 rows affected (0.00 sec)

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> 
    
    

Creating mysql tables

To keep systems that can relay over our postfix we need to create table 'access'. Field 'ip' has single computers' IP addresses or wildcards. Field 'action' has 'OK' to allow a computer to relay over our system or 'REJECT' in opposite case.
    create table access (
	ip varchar(255) default NULL,
	action varchar(255) default NULL
    );
    insert into(access,action) values('127.0.0.1', 'OK');
    insert into(access,action) values('10.', 'OK');
    insert into(access,action) values('192.168.', 'OK');
    
To use SMTP-After-POP we need to create a table that will have ip address of users who has authorized at POP3 server and able to send emails over SMTP. This table keeps IP addresses temporary only and gets cleaned for records out of date. Field 'ts' has timestamp of authorized user.
    create table relay_ip (
        ip char(15) NOT NULL default '',
        ts int(11) NOT NULL default '0',
        key ip (ip)
    );
    
To forward mail from one to another one we can use table 'aliases'. Field 'alias' has email address, 'rcpt' has receipter's address.
    create table aliases (
        alias varchar(255) NOT NULL default '',
	rcpt varchar(255) NOT NULL default '',
	comment text,
	PRIMARY KEY  (alias)
    );
    insert into(alias,action) values('sales@domain.com', 'tom@domain.com');
    insert into(alias,action) values('support@domain.com', 'jack@domain.com');
		
    
If we use several transports like procmail or virtual: to deliver mail to local users we can use table 'transport'.
    create table transport (
	domain varchar(255) NOT NULL default '',
	transport varchar(255) NOT NULL default '',
	comment text,
	PRIMARY KEY  (domain)
    );
    
And finally, our own table has users' accounts.
    create table users (	
	email varchar(128) NOT NULL default '',
	passwd varchar(128) NOT NULL default '',
	uid int(11) unsigned NOT NULL default '514',
	gid int(11) unsigned NOT NULL default '514',
	maildir varchar(255) NOT NULL default '/var/spool/mail',
	enabled tinyint(4) NOT NULL default '1',
	status tinyint(4) NOT NULL default '1',
	quota int(11) unsigned NOT NULL default '2048000',
	username varchar(80) NOT NULL default '',
	PRIMARY KEY  (email)
    );
    insert into users (email, password, maildir, username) 
        values ('tom@domain.com', password('tompass875'), '/var/spool/mail/tom@domain.com/', 'tom@domain.com');
    insert into users (email, password, maildir, username) 
        values ('jack@domain.com', password('jackpass875'), '/var/spool/mail/jack@domain.com/', 'jack@domain.com');
	    
    
FieldField description
email Email address of a user. May have either @domain.com or user@domain.com records.
passwd Encrypted password of a user. Should be updated by MySQL 'PASSWORD(mysqlpassword)' function.
uid, gid Numerical UID and GID of user postfix that we have created before
maildir Path to maildir of a user. Since we use maildir, it MUST be finished by '/' at the end otherwise postfix will deliver mail into mailbox instead of maildir.
enabled Fields that activates a user. Not used yet, you can use it for in future.
status Fields that activates a user. Not used yet, you can use it for in future.
quota A field to limit user's disk space in bytes. By default it's 2GB.
username We use different field username in case if you decide to change email address but not bother user asking to change his mail software's setting.


This mysql initilization SQL-statement can be taken at http://smartcgi.com/dist/postfix/config/create-db.mysql  It doesn't have examples of domains and email addresses. You have to insert your own as have been shown above.

List of content



© Copyright 1999 - 2004 SmartCGI, Inc. All Rights Reserved.