异形技术 Abnormity Network Tech

基于Fedora上建立功能强大的邮件服务器
  
  一、软件的准备
  A.检查你的系统是否已安装了以下软件
  1.pam
  2.pam-devel
  3.mysql
  4.mysql-servel
  5.mysql-devel
  6.imap-devel
  7.sharutils
  
  B.下载以下软件
  1.metamail*.i386.rpm
  2.pam-mysql
  3.cyrus-sasl-2.1.15
  4.postfix-2.0.16
  5.courier-imap
  
  C.说明
  
  mysql-devel在第3个盘。我忘了装,结果pam-mysql和postfix的编译过不了。metamail和sharutils是取验证码用的。
  
  二、mysql数据库和表的建立
  A.[root@localhost root]# mysql
  
  Welcome to the MySQL monitor. Commands end with ; or \g.
  Your MySQL connection id is 3 to server version: 3.23.58
  
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  
  mysql> use mysql
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  
  Database changed
  mysql> INSERT INTO db (Host,Db,User,Select_priv)VALUES('localhost','postfix','postfix','Y');
  Query OK, 1 row affected (0.00 sec)
  
  mysql> CREATE DATABASE postfix;
  Query OK, 1 row affected (0.00 sec)
  
  mysql> GRANT ALL ON postfix.* TO postfix@localhost
  -> IDENTIFIED BY "postfix";
  Query OK, 0 rows affected (0.00 sec)
  
  mysql> FLUSH PRIVILEGES;
  Query OK, 0 rows affected (0.00 sec)
  
  mysql> quit
  Bye
  
  B.把下列文字复制存为postfix.sql
  
  ########potfix_sql########bigin##################
  CREATE TABLE alias (
  username varchar(255) NOT NULL default'',
  goto text NOT NULL,
  domain varchar(255) NOT NULL default'',
  PRIMARY KEY (username)
  ) TYPE=MyISAM;
  CREATE TABLE domain (
  domain varchar(255) NOT NULL default'',
  description varchar(255) NOT NULL default'',
  PRIMARY KEY (domain)
  ) TYPE=MyISAM;
  
  CREATE TABLE mailbox (
  userid char(20) binary NOT NULL default'',
  username varchar(255) NOT NULL default'',
  password varchar(255) NOT NULL default'',
  home varchar(255) NOT NULL default'',
  maildir varchar(255) NOT NULL default'',
  name varchar(255) NOT NULL default'',
  uid smallint(5) unsigned NOT NULL default'12345',
  gid smallint(5) unsigned NOT NULL default'12345',
  quota varchar(255) NOT NULL default'',
  domain varchar(255) NOT NULL default'',
  create_date date NOT NULL default'0000-00-00',
  create_time time NOT NULL default'00:00:00',
  change_date date NOT NULL default'0000-00-00',
  change_time time NOT NULL default'00:00:00',
  last_access int(10) unsigned NOT NULL default'0',
  passwd_lastchanged int(10) unsigned NOT NULL default'0',
  status tinyint(4) NOT NULL default'1',
  PRIMARY KEY (username),
  KEY status (status)
  ) TYPE=MyISAM;
  #####################end########################
  
  [root@localhost root]# mysql postfix < /work/postfix.sql
  
  C.对表的内容的一些说明.
  
  mysql> use postfix
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  
  Database changed
  mysql> show tables;
  +-------------------+
  | Tables_in_postfix |
  +-------------------+
  | alias       |
  | domain      |
  | mailbox      |
  +-------------------+
  3 rows in set (0.00 sec)
  
  mysql> desc alias;
  +----------+--------------+------+-----+---------+-------+
  | Field  | Type     | Null | Key | Default | Extra |
  +----------+--------------+------+-----+---------+-------+
  | username | varchar(255) |   | PRI |     |    |
  | goto   | text     |   |   |     |    |
  | domain  | varchar(255) |   |   |     |    |
  +----------+--------------+------+-----+---------+-------+
  3 rows in set (0.00 sec)
  
  mysql> desc domain;
  +-------------+--------------+------+-----+---------+-------+
  | Field    | Type     | Null | Key | Default | Extra |
  +-------------+--------------+------+-----+---------+-------+
  | domain   | varchar(255) |   | PRI |     |    |
  | description | varchar(255) |   |   |     |    |
  +-------------+--------------+------+-----+---------+-------+
  2 rows in set (0.00 sec)
  
  mysql> desc mailbox;
  +--------------------+----------------------+------+-----+------------+-------+
  | Field       | Type         | Null | Key | Default  | Extra |
  +--------------------+----------------------+------+-----+------------+-------+
  | userid       | varchar(20) binary  |   |   |      |    |
  | username      | varchar(255)     |   | PRI |      |    |
  | password      | varchar(255)     |   |   |      |    |
  | home        | varchar(255)     |   |   |      |    |
  | maildir      | varchar(255)     |   |   |      |    |
  | name        | varchar(255)     |   |   |      |    |
  | uid        | smallint(5) unsigned |   |   | 12345   |    |
  | gid        | smallint(5) unsigned |   |   | 12345   |    |
  | quota       | varchar(255)     |   |   |      |    |
  | domain       | varchar(255)     |   |   |      |    |
  | create_date    | date         |   |   | 0000-00-00 |    |
  | create_time    | time         |   |   | 00:00:00  |    |
  | change_date    | date         |   |   | 0000-00-00 |    |
  | change_time    | time         |   |   | 00:00:00  |    |
  | last_access    | int(10) unsigned   |   |   | 0     |    |
  | passwd_lastchanged | int(10) unsigned   |   |   | 0     |    |
  | status       | tinyint(4)      |   | MUL | 1     |    |
  +--------------------+----------------------+------+-----+------------+-------+
  17 rows in set (0.00 sec)
  
  mysql>
  domain表的解释:
  domain 任意的domain.
  description 通常是2种 "local:" 用于本地的 or "virtual:" 用于是虚拟的.
  alias表的解释:
  username 是虚拟的邮箱address@domain.tld ,将被转发到goto下的联结中.
  goto 可以用简单的名字,如果是本地用户名,如(root, postmaster, etc.), 或者是整个的邮箱名字,user@domain.tld。
  
  Mailbox表的内容:
  Userid 使用者编码
  username 可以是user.domain.tld 或 user@domain.tld
  password 在mysql中用encrypt('password') 输入.
  name 使用着的真实姓名。
  uid 虚拟用户身份uid
  gid 组的gid
  home "/usr/local/virtual/". Maildirs必须在此目录下。
  domain 这栏可以不要,但有些软件需要他。
  maildir 是整个地址,必须带”/”结尾。
  Quota 邮箱的空间或信息量的限制。
  status 0 为禁止。"MYSQL_WHERE_CLAUSE= status" .
  
  三、pam-mysql的编译
  tar pam-mysql-5.0.tar.gz
  make cp pam_mysql.so /lib/security
  
  四、修改pam
  [root@localhost  pam_mysql]#  cd  /etc/pam.d
  [root@localhost  pam.d]#  cp  /work/postfix  postfix
  [root@localhost  pam.d]#
  postfix的内容如下:
  ##########/etc/pam.d/postfix##################
  echo  auth  sufficient  pam_mysql.so  user=postfix  passwd=postfix  host=localhost  db=postfix  table=mailbox  usercolumn=username  passwdcolumn=password  crypt=1
  echo  account  requir

好评   好评率(49.09%)   差评
Posted on 2009/1/30 2:22:00 by 异形技术 浏览50409次