• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 中小規模POSTFIX郵件系統

    發表于:2007-05-25來源:作者:點擊數: 標簽:
    整個安裝描述過程是基于FreeBSD 4.7環境下的,全部功能都安裝在一臺 服務器 上,并且擁有mail.localhost.com域名。 1.安裝webmin 下載webmin-1.070.tar.gz #tar zxvf webmin-1.070.tar.gz #cd webmin-1.070 #./setup.sh 安裝后可以對mysql 數據庫 進行管理
    整個安裝描述過程是基于FreeBSD 4.7環境下的,全部功能都安裝在一臺服務器上,并且擁有mail.localhost.com域名。

    1.安裝webmin
    下載webmin-1.070.tar.gz
    #tar zxvf webmin-1.070.tar.gz
    #cd webmin-1.070
    #./setup.sh
    安裝后可以對mysql數據庫進行管理,比如添加用戶,向表里添加數據。

    2.數據庫的設置

    2.1、安裝mysql數據庫

    本系統使用的是FreeBSD 4.7下ports安裝的mysql數據庫(當時使用原碼安裝時在安裝postfix時出錯,所以使用ports安裝就解決了該問題)。

    #cd /usr/ports/databases/mysql323-server/
    #make install
    #cd work/mysql-3.23.52/
    #scripts/mysql_install_db
    #cp support-files/my-medium.cnf /etc/my.cnf
    #echo “/usr/local/bin/safe_mysqld --user=mysql &” >> /etc/rc.local
    #/usr/local/bin/safe_mysqld --user=mysql & 啟動mysql服務

    2.2、設置數據庫

    2.2.1、添加mysql用戶:

    1、使用webmin->mysql數據庫服務器->用戶權限,添加用戶postfix,密碼postfix,主機localhost,并設置擁有相應的權限。

    2、使用SQL語句添加用戶:
    #cd /usr/local/bin
    #./mysql –D mysql –p
    Password:
    mysql>INSERT INTO user (host,user,password)
    ->VALUES (‘localhost’,‘postfix’,’’);
    Query OK. I row affected (0.00 sec)
    mysql>UPDATA user SET password=password(‘postfix’)
    ->WHERE user=’postfix’;
    Rows matched: 1 Changed: 1 Warnings: 0
    mysql>FLUSH PRIVILEGES;
    Query OK. 0 rows affected (0.01 sec)
    mysql>GRANT select,insert,update on mail.* TO postfix
    Query OK. 0 rows affected (0.01 sec)
    mysql>exit

    2.2.2、向數據庫中添加表

    #cd /usr/local/bin/
    #ee postfix.sql

    CREATE DATABASE;
    GRANT ALL ON mail.* mail@localhost IDENTIFIED BY “postfix”;
    FLUSH PRIVILEGES;
    use mail;
    CREATE TABLE forward (
    username varchar(255) NOT NULL default ‘’, //本機地址
    forward_addr varchar(255) default NULL, //轉發地址
    PRIMARY KEY (username)
    ) TYPE=MyISAM;
    CREATE TABLE transport (
    domain varchar(255) NOT NULL default ‘’, //郵件域
    transport varchar(icon_cool.gif default NULL, //處理方式
    PRIMARY KEY (domain)
    ) TYPE=MyISAM;
    CREATE TABLE users (
    username varchar(128) NOT NULL default ‘’, //用戶名
    domain varchar(128) NOT NULL default ‘’, //郵件域
    address varchar(128) NOT NULL default ‘’, //郵件地址
    password varchar(128) NOT NULL default ‘’, //用戶密碼(明文)
    uid int(6) NOT NULL default ‘1024’, //uid
    gid int(6) NOT NULL default ‘1024’, //gid
    home varchar(255) NOT NULL default ‘/’, //home目錄
    maildir varchar(255) NOT NULL default ‘’, //maildir目錄
    quota varchar(255) NOT NULL default ‘’, //郵箱容量
    mailok tinyint(3) NOT NULL default ‘1’,
    bool1 tinyint(3) NOT NULL default ‘1’,
    bool2 tinyint(3) NOT NULL default ‘1’,
    PRIMARY KEY (address),
    UNIQUE KEY address (address),
    KEY address_2 (address)
    ) TYPE=MyISAM;

    輸入完畢后保存退出。
    #./mysql –u postfix –p < postfix.sql
    #password:postfix

    2.2.3、向表中添加數據

    #/usr/local/bin
    #./mysql –u postfix –p
    password:******
    mysql>use mail
    mysql>INSERT INTO transport (domain,transport)
    ->VALUES (’localhost.com’,’virtual:’);
    mysql>INSERT INTO users (username,domain,address,password,uid,gid,
    home,maildir,quota,mailok,bool1,bool2)
    ->VALUES (‘test’,’localhost.com’,’test.localhost.com’,
    ’test’,’1024’,’1024’,’/’,
    ’/var/postfix_mail/test/Maildir/’,’5000000’,’1’,’1’,’1’);
    mysql>exit

    3.安裝CYRUS-SASL

    #tar –zxvf cyrus-sasl-1.5.27
    #cd cyrus-sasl-1.5.27
    #./configure --with-pwcheck=/var/pwcheck --enable-login
    --enable-plain
    #make
    #make install

    #echo /usr/local/lib/ >> /etc/ld.so.conf
    #echo /usr/local/lib/mysql/ >> /etc/ld.so.conf
    #ldconfig

    #cp /usr/local/include/* /usr/include
    #cp /usr/local/lib/lib*.* /usr/lib

    #ln –s /usr/local/lib/sasl /usr/lib/sasl
    #ln –s /usr/local/include/mysql /usr/include/mysql
    #ln –s /usr/local/lib/mysql /usr/lib/mysql

    在/usr/local/lib/sasl下建立文件smtpd.conf,添加一下內容:
    pwcheck_method:mysql
    mysql_user:postfix
    mysql_passwd:postfix
    mysql_host:localhost
    mysql_database:mail
    mysql_table:users
    mysql_uidcol:address
    mysql_pwdcol:password

    4.安裝和設置postfix

    4.1、安裝postfix

    4.4.1、編譯/etc/rc.conf,設置sendmail_enable=”NO”

    #mv /usr/bin/newaliases /usr/bin/newaliases.OFF
    #mv /usr/bin/mailq /usr/bin/mailq.OFF
    #mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
    #pw groupadd postfix –g 1024
    #pw groupadd postdrop –g 1025
    #pw useradd postfix –u 1024 –g postfix
    #echo ‘postfix:root’ >> /etc/aliases

    4.4.2、安裝postfix和相應的quota補丁

    #tar zxvf postfix-1.1.11.tar.gz
    #patch < postfix-1.1.11_quota_maildirsize.patch
    #make –f Makefile.init makefiles ‘CCARGS=-DUSE_SASL_AUTH –DHAS_MYSQL –I/usr/include/mysql’ ‘AUXLIBS=-L/usr/lib/mysql –lmysqlclient –lasal –lz –lm’
    #make
    #make install 按照默認路徑一路回車就可以安裝成功postfix,如果出錯,在提示“tempdir”時輸入:/tmp,這樣一般就可以通過。

    4.2、設置postfix

    postfix默認安裝到/etc/postfix目錄下,設置文件也在這
    #cd /etc/postfix

    4.2.1、編譯主配置文件main.cf

    #ee main.cf 添加如下內容

    #Base configure
    myhostname = mail.localhost.com //本機的機器名
    mydomain = local.com //域名
    mynetworks = 127.0.0.0/8 192.168.0.0/16 //允許不經smtp認證能發信的ip段
    home_mailbox = Maildir/ //使用的郵箱格式為Maildir/
    smtpd_banner = Welcome to localhost.com mail system! //smtp的歡迎信息

    #Mysql configure
    transport_maps = mysql:/etc/postfix/transport.cf //指定那些域的郵件可以被postfix收下來
    virtual_mailbox_base =/ //指定用戶郵箱所在的根目錄
    virtual_uid_maps = mysql:/etc/postfix/ids.cf //指定postfix帳號的ID
    virtual_gid_maps = mysql:/etc/postfix/gds.cf //指定postfix組的ID
    virtual_mailbox_maps = mysql:/etc/postfix/users.cf //指定用戶郵箱的目錄
    virtual_maps = mysql:/etc/postfix/forward.cf //指定自動轉發郵件的設置
    #Quota configure
    message_size_limit = 5000000 //單個郵件大小的限制
    virtual_mailbox_limit = 5000000 //默認的郵箱大小
    virtual_mailbox_limit_maps = mysql:/etc/postfix/quota.cf //每個用戶的郵箱大小
    virtual_mailbox_limit_override = yes //是否允許覆蓋默認的郵箱大小

    #smtp configure
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = $myhostname
    smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated permit_auth_destination reject
    smtpd_sasl_security_options = noanonymous
    smtpd_client_restrictions = permit_sasl_authenticated

    inet_interfaces = all //監聽所有端口
    inet_interfaces = 192.168.80.21 //是外面的用戶也可以發送郵件

    4.2.2、查看master.cf文件必須包含下面一行

    virtual unix - n n - - virtual

    4.2.3、編譯transport.cf

    #touch transport.cf
    #ee transport.cf 添加如下內容
    user = postfix
    password = postfix
    dbname = mail
    table = transport
    select_field = transport
    where_field = domain
    hosts = localhost

    4.2.4、編譯ids.cf

    #touch ids.cf
    #ee ids.cf
    user = postfix
    password = postfix
    dbname = mail
    table = users
    select_field = uid
    where_field = address
    hosts = localhost
    4.2.5、編譯gds.cf

    #touch gds.cf
    #ee gds.cf
    user = postfix
    password = postfix
    dbname = mail
    table = users
    select_field = gid
    where_field = address
    hosts = localhost

    4.2.6、編譯forward.cf

    #touch forward.cf
    #ee forward.cf
    user = postfix
    password = postfix
    dbname = mail
    table = forward
    select_field = forward_addr
    where_field = username
    hosts = localhost

    4.2.7、編譯users.cf

    #touch users.cf
    #ee users.cf
    user = postfix
    password = postfix
    dbname = mail
    table = users
    select_field = maildir
    where_field = address
    hosts = localhost

    4.2.8、編譯quota.cf

    #touch quota.cf
    #ee quota.cf
    user = postfix
    password = postfix
    dbname = mail
    table = users
    select_field = quota
    where_field = address
    hosts = localhost

    4.3、啟動postfix

    #/usr/sbin/postfix start
    postfix/postfix-script: starting the Postfix mail system

    #echo “/usr/sbin/postfix start” >> /etc/rc.local

    #telnet localhost 25
    Connected to localhost.localhost.com.
    Escape character is ‘^]’.
    220 Welcome to localhost mail system!

    4.4、測試postfix

    4.4.1、建立mail郵件存放目錄
    #cd /var
    #mkdir postfix_mail
    #chown –R postfix:postfix /var/postfix_mail

    4.4.2、使用客戶端發郵件
    此時可以使用客戶端的foxmail或者outlook向用戶test.localhost.com發送郵件,然后到/var/postfix/test/Maildir/下查看郵件,如果能收到說明SMTP已經工作正常了,如果有問題仔細檢查自己的每個步驟。

    5.安裝設置courier-imap

    5.1、安裝courier-imap

    #cd /usr/ports/mail/courier-imap
    #make
    #cd work/courier-imap-1.5.3
    #./configure –with-db=db –without-socks –disable-root-check
    #make
    #make install
    #/usr/lib/courier-imap/libexec/authlib/authdaemon start
    #echo “/usr/lib/courier-imap/libexec/authlib/authdaemon start” >> /etc/rc.local

    5.2、添加用戶

    #cd /usr/local/bin
    #./mysql –D mysql –p
    password:*******
    mysql>INSERT INTO user (host,user,password)
    ->VALUES (‘localhost’,’courier’,’’);
    mysql>UPDATA user SET password=password(‘haha’)
    ->WHERE user=’courier’;
    mysql>FLUSH PRIVILEGES;
    mysql>GRAN select,insert,update on mail.* TO courier;
    mysql>exit

    5.3、設置courier-imap

    #cd /usr/lib/courier-imap/etc
    #cp authdaemonrc.dist authdaemonrc
    #cp authmysqlrc.dist authmysqlrc
    #cp imapd.dist imapd
    #cp imapd-ssl.dist imapd-ssl
    #cp pop3d.dist pop3d
    #cp pop3d-ssl pop3d-ssl

    #ee pop3d

    prefix=/usr/lib/courier-imap
    exec_prefix=/usr/lib/courier-imap
    sbindir=”/usr/lib/courier-imap/sbin”

    PIDFILE=/var/run/pop3d.pid
    MAXDAEMONS=40
    MAXPERIP=4
    AUTHMODULES=”authdaemon”
    AUTHMODULES_ORIG=”authdaemon”
    POP3AUTH=””
    POP3AUTH_ORIG=”LOGIN CRAM-MD5 CRAM-SHA1”
    POP3AUTH_TLS=””
    POP3AUTH_TLS_ORIG=”LOGIN PLAIN”
    PORT=110
    ADDRESS=0
    TCPDOPTS=”-nodnslookup -noidentlookup”
    POP3DSTART=YES

    #ee imapd

    IMAPDSTART=YES

    #ee authdaemonrc
    authmodulelist=”authmysql authpam”
    authmodulelistorig=”authcustom authcram authuserdb authmysql authpam”
    daemons=5
    version=”authdaemond.mysql”
    authdaemonvar=”/usr/lib/courier-imap/var/authdaemon”

    #ee authmysqlrc
    MYSQL_SERVER localhost
    MYSQL_USERNAME courier
    MYSQL_PASSWORD haha
    MYSQL_SOCKET /tmp/mysql.sock
    MYSQL_PORT 3306
    MYSQL_OPT 0
    MYSQL_DATABASE mail
    MYSQL_USER_TABLE users
    #MYSQL_CRYPT_PWFIELD password
    MYSQL_CLEAR_PWFIELD password
    MYSQL_UID_FIELD uid
    MYSQL_GID_FIELD gid
    MYSQL_LOGIN_FIELD address
    MYSQL_HOME_FIELD home
    MYSQL_NAME_FIELD username
    MYSQL_MAILDIR_FIELD maildir
    MYSQL_QUOTA_FIELD quota
    MYSQL_WHERE_CLAUSE mailok=1

    #cd ..
    #ln -s /usr/lib/courier-imap/libexec/imapd.rc imapd
    #ln -s /usr/lib/courier-imap/libexec/pop3d.rc pop3d
    #./imapd start
    #echo “/usr/lib/courier-imap/imap start” >> /etc/rc.local
    #./pop3d start
    #echo “/usr/lib/courier-imap/pop3 start” >> /etc/rc.local
    #netstat –an | grep LISTEN
    tcp4 0 0 *:110 *:* LISTEN
    tcp46 0 0 *:110 *:* LISTEN
    tcp4 0 0 *:143 *.* LISTEN
    tcp46 0 0 *.143 *.* LISTEN

    #telnet localhost 110
    Trying 127.0.0.1...
    Connected to localhost.cw-isquare.com.
    Escape character is ‘^]’.
    +OK Hello there
    #quit

    #telnet localhost 143
    *OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc. See COPYING for distribution information.
    #quit

    5.安裝設置sqwebmail

    5.1、安裝sqwebmail-3.5.0-cn.tar.gz

    #tar zxvf sqwebmail-3.5.0.tar.gz
    #cd sqwebmail-3.5.0
    #./configure --without-authpam –with-db=db --enable-webpass=no --without-authpwd --without-authshadow
    #make configure-check
    #make
    #make install-strip
    #make install-configure

    #/usr/local/share/sqwebmail/libexec/authlib/authdaemond start
    #echo “/usr/local/share/sqwebmail/libexec/authlib/authdaemond start” >> /etc/rc.local

    5.2、配置sqwebmail-3.5.0

    5.2.1、安裝apache
    #tar apache_1.3.22.tar.gz
    #cd apache_1.3.22
    #./configure –prefix=/usr/local/apache
    #make
    #make install

    5.2.2、設置sqwebmail
    #cd /usr/local/share/sqwebmail
    #ee authdaemonrc
    authmodulelist=”authmysql authpam”
    authmodulelistorig=”authcustom authcram authuserdb authmysql authpam”
    daemons=5
    version=”authdaemond.mysql”
    authdaemonvar=”/usr/local/share/sqwebmail/var/authdaemon”

    #ee authmysqlrc
    MYSQL_SERVER localhost
    MYSQL_USERNAME courier
    MYSQL_PASSWORD haha
    MYSQL_SOCKET /tmp/mysql.sock
    MYSQL_PORT 3306
    MYSQL_OPT 0
    MYSQL_DATABASE mail
    MYSQL_USER_TABLE users
    #MYSQL_CRYPT_PWFIELD password
    MYSQL_CLEAR_PWFIELD password
    MYSQL_UID_FIELD uid
    MYSQL_GID_FIELD gid
    MYSQL_LOGIN_FIELD address
    MYSQL_HOME_FIELD home
    MYSQL_NAME_FIELD username
    MYSQL_MAILDIR_FIELD maildir
    MYSQL_QUOTA_FIELD quota
    MYSQL_WHERE_CLAUSE mailok=1


    5.2.3、測試sqwebmail-3.5.0

    在客戶端的瀏覽器的地址欄輸入
    http://mail.localhost.com/cgi-bin/sqwebmail
    輸入用戶名和密碼就可以登錄進去收發郵件了。
    注意:用戶名一定要輸入全稱,也就是連域名一起輸入。

    5.2.4、設置apache頁面跳轉

    #cd /usr/local/apache/htdocs
    #touch index.html
    #ee index.html

    <meta http-equiv=”refresh” content=”0;URL=http://mail.localhost
    .com/cgi-bin/sqwebmail?index=1”>

    現在就可以直接在IE的地址欄輸入:
    http://mail.localhost.com
    來訪問sqwebmail了

    這篇文章沒有加入smtp認證,上次有個朋友在帖子里說過加認證的方法,由于沒有時間,所以我就沒有試。還有沒有郵件列表的問題,我找不到解決的方法,如果有朋友看到這篇文章請把smtp認證和郵件列表功能補充一下,這要就比較完整了。在此我先表示感謝~


    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>