database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Tutorials 14690 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 14690
Postfix + Mysql
작성자
정재익(advance)
작성일
2002-01-10 22:55
조회수
6,434

Postfix + MySQL

 

Index:

Disclaimer

Postfix install

main.cf

Config files

 

MySQL setup

Table explanation

The \transport\ table

The \aliases\ table

the \remote_aliases\ table

 

Additional notes

 

Disclaimer:

 

This HOWTO is based on the assumption that you have a good deal of knowledge of Postfix and MySQL.

The howto is based on the latest snapshot of postfix (20010808).

The virtual agent is not in the stable version of postfix yet.

Furthermore you need to have read MYSQL_README and VIRTUAL_README (snapshot only)

and basicly everything else there is to read.

 

This is a step by step HOWTO of how to setup the virtual part of postfix.

 

Postfix install:

 

Unpack postfix.

Do (inside the postfix directory):

make -f Makefile.init makefiles \

\CCARGS=-DHAS_MYSQL -I/some/where/mysql/include\ \

\AUXLIBS=/some/where/mysql/lib -lmysqlclient -lz -lm\

make && make install

cp the virtual bin from the virtual directory into the postfix directory. ie: cp src/virtual/virtual /usr/libexec/postfix

 

Replace the \/some/where/\ with your system\s path.

 

Now setup Postfix as you usually would, but almost all the mapping is

done through MySQL.

 

main.cf:

 

transport_maps = mysql:/etc/postfix/transport.cf

virtual_mailbox_base = /data/mail

virtual_uid_maps = mysql:/etc/postfix/ids.cf

virtual_gid_maps = mysql:/etc/postfix/ids.cf

virtual_mailbox_maps = mysql:/etc/postfix/aliases.cf

virtual_maps = mysql:/etc/postfix/remote_aliases.cf

 

Config files:

 

transport.cf:

user = postfix

password = postfix

dbname = mail

table = transport

select_field = transport

where_field = domain

hosts = localhost

 

ids.cf:

user = postfix

password = postfix

dbname = mail

table = aliases

select_field = id

where_field = alias

hosts = localhost

 

aliases.cf:

user = postfix

password = postfix

dbname = mail

table = aliases

select_field = maildir

where_field = alias

hosts = localhost

 

remote_aliases.cf:

user = postfix

password = postfix

dbname = mail

table = remote_aliases

select_field = rcpt

where_field = alias

hosts = localhost

 

Also remember that relay_domains needs to contain $transport_maps to lookup local virtual domains.

alias_maps does not affect the virtual agent.

 

MySQL Setup:

 

Create a mysql user/database for postfix:

gaia:~# mysql

mysql> use mysql;

mysql> insert into user (Host, User, Password) values(\localhost\,\postfix\, password(\postfix\));

mysql> insert into db (Host, Db, User, Select_priv) values(\localhost\,\mail\,\postfix\,\Y\);

mysql> create database mail;

 

Create the tables needed:

mysql> use mail;

mysql> create table transport (domain varchar(255) PRIMARY KEY, transport char(8));

mysql> create table aliases (id int(6), alias varchar(255) PRIMARY KEY, maildir varchar(255));

mysql> create table remote_aliases (alias varchar(255) PRIMARY KEY, rcpt varchar(255));

 

Finish off by reloading the mysql server:

 

gaia:~# mysqladmin reload

 

Table explanation:

 

The \transport\ table (from the man page):

 

The optional transport table specifies a mapping from

domain hierarchies to message delivery transports and/or

relay hosts. The mapping is used by the trivial-rewrite(8)

daemon.

 

Example:

mysql> select * from transport;

+-----------+-----------+

| domain | transport |

+-----------+-----------+

| gostil.dk | virtual: |

+-----------+-----------+

 

The \aliases\ table:

 

This table is used for 2 things:

 

1: Map aliases to mailboxes / maildirs.

2: Map uid/gids to mailboxes.

 

Example:

 

mysql> select * from aliases;

+------+---------------+------------------------+

| id | alias | maildir |

+------+---------------+------------------------+

| 1002 | dvp@gostil.dk | gostil.dk/dvp/Maildir/ |

+------+---------------+------------------------+

 

The \remote_aliases\ table:

 

This final table is used to map aliases at one domain

to aliases at another domain.

 

Example:

mysql> select * from remote_aliases;

+----------------+----------------+

| alias | rcpt |

+----------------+----------------+

| test@gostil.dk | daniel@rtfm.dk |

+----------------+----------------+

[/pre]

Additional Notes:

 

The base directory needs to be owned by whichever user

you chose when installing postfix (in my case, maildrop).

The permissions need to be 0700.

When the first mail is sent to one of your aliases the rest is

auto magically created by Postfix.

 

원본 출처 : http://kummefryser.dk/HOWTO/mail/postfix_mysql.html

[Top]
No.
제목
작성자
작성일
조회
14867mysqlfs (MySQL filesystem) [1]
정재익
2002-01-20
8413
14789pconnect와 thread좀비..그리고 mysqladmin [3]
이재원(운비)
2002-01-15
8402
14729MySQL C API
정재익
2002-01-11
10037
14690Postfix + Mysql
정재익
2002-01-10
6434
14658Using MySQL with XML
정재익
2002-01-09
7874
14622ERROR 2003: Can't connect to MySQL server on 'localhost' <10061>
황동철
2002-01-08
18980
14582MySQL 에서 사용자와 권한 설정 [2]
정재익
2002-01-06
18452
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.019초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다