在Fedora上建立自己的郵件服務(wù)器.doc_第1頁
在Fedora上建立自己的郵件服務(wù)器.doc_第2頁
在Fedora上建立自己的郵件服務(wù)器.doc_第3頁
在Fedora上建立自己的郵件服務(wù)器.doc_第4頁
在Fedora上建立自己的郵件服務(wù)器.doc_第5頁
已閱讀5頁,還剩14頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

5、sendmail配置 要sendmail正常運行,還需配置幾個文件,首先最重要的就是sendmail.cf 文件了。它在源碼目錄樹下的cf/cf目錄下有很多例子可參考。你可以拷貝使用。由于sendmail.cf中的語法很復(fù)雜,所以不建議手工修改。我們可以以sendmail.mc文檔配合sendmail-cf目錄下的宏通過m4預(yù)處理器自動生成。m4預(yù)處理器用來從一組宏文件中創(chuàng)建sendmail配置文件。宏文件作為輸入被讀進來。宏被展開,然后寫到一個輸出文件。sendmail-cf目錄一般放在/usr/share目錄下。其實sendmail-cf目錄的內(nèi)容和源碼目錄樹下的cf目錄的內(nèi)容是一樣的,所以,為了保證sendmail-cf目錄的內(nèi)容與安裝版本同步,要把源碼目錄樹下的cf目錄的內(nèi)容拷貝到/usr/share/sendmail-cf目錄。 sendmail.mc配置文檔內(nèi)容如下: divert(-1) include(/usr/share/sendmail-cf/m4/cf.m4) VERSIONID(linux setup for Red Hat Linux)dnl OSTYPE(linux) dnl Uncomment and edit the following line if your mail needs to be sent out dnl through an external mail server: dnl define(SMART_HOST,vider) define(confDEF_USER_ID,8:12)dnl undefine(UUCP_RELAY)dnl undefine(BITNET_RELAY)dnl dnl define(confAUTO_REBUILD)dnl define(confTO_CONNECT, 1m)dnl define(confTRY_NULL_MX_LIST,true)dnl define(confDONT_PROBE_INTERFACES,true)dnl define(PROCMAIL_MAILER_PATH,/usr/bin/procmail)dnl define(ALIAS_FILE, /etc/mail/aliases)dnl define(STATUS_FILE, /etc/mail/statistics)dnl define(UUCP_MAILER_MAX, 2000000)dnl define(confUSERDB_SPEC, /etc/mail/userdb.db)dnl define(confPRIVACY_FLAGS, authwarnings,novrfy,noexpn,restrictqrun)dnl define(confAUTH_OPTIONS, A)dnl TRUST_AUTH_MECH(EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN)dnl define(confAUTH_MECHANISMS, EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN)dnl dnl define(confCACERT_PATH,/usr/share/ssl/certs) dnl define(confCACERT,/usr/share/ssl/certs/ca-bundle.crt) dnl define(confSERVER_CERT,/usr/share/ssl/certs/sendmail.pem) dnl define(confSERVER_KEY,/usr/share/ssl/certs/sendmail.pem) dnl define(confTO_QUEUEWARN, 4h)dnl dnl define(confTO_QUEUERETURN, 5d)dnl dnl define(confQUEUE_LA, 12)dnl dnl define(confREFUSE_LA, 18)dnl define(confTO_IDENT, 0)dnl dnl FEATURE(delay_checks)dnl FEATURE(no_default_msa,dnl)dnl FEATURE(smrsh,/usr/sbin/smrsh)dnl FEATURE(mailertable,hash -o /etc/mail/mailertable.db)dnl FEATURE(virtusertable,hash -o /etc/mail/virtusertable.db)dnl FEATURE(redirect)dnl FEATURE(always_add_domain)dnl FEATURE(use_cw_file)dnl FEATURE(use_ct_file)dnl dnl The -t option will retry delivery if e.g. the user runs over his quota. FEATURE(local_procmail,procmail -t -Y -a $h -d $u)dnl FEATURE(access_db,hash -T -o /etc/mail/access.db)dnl FEATURE(blacklist_recipients)dnl EXPOSED_USER(root)dnl dnl This changes sendmail to only listen on the loopback device dnl and not on any other network devices. Comment this out if you want dnl to accept email over the network. DAEMON_OPTIONS(Port=smtp,Addr=, Name=MTA) dnl NOTE: binding both IPv4 and IPv6 daemon to the same port requires dnl a kernel patch dnl DAEMON_OPTIONS(port=smtp,Addr=:1, Name=MTA-v6, Family=inet6) dnl We strongly recommend to comment this one out if you want to protect dnl yourself from spam. However, the laptop and users on computers that do dnl not have 24x7 DNS do need this. FEATURE(accept_unresolvable_domains)dnl dnl FEATURE(relay_based_on_MX)dnl MAILER(smtp)dnl MAILER(procmail)dnl 記得要使以下兩個條語句有效,它的意思是如果access.db訪問控制沒有設(shè)置,則啟用以下驗證方式進行smtp驗證。 TRUST_AUTH_MECH(EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN)dnl define(confAUTH_MECHANISMS, EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN)dnl sendmail宏定義說明 divert(n) 為m4定義一個緩沖動作,當n=-1時緩沖被刪除,n=0時開始一個新緩沖OSTYPE 定義宏所使用的操作系統(tǒng),該宏允許m4程序增加同相關(guān)操作系統(tǒng)相關(guān)的文件 Domain 定義MTA將使用哪些域來傳輸郵件 Feature 定義配置文件中使用的一個特定的功能集 Define 定義配置文件中的一個特定的選項值 MASQUERADE_AS 定義sendmail來應(yīng)答郵件的其它主機名 MAILER 定義sendmail使用的郵件傳輸方法 dnl 注釋 完成sendmail.mc文檔的編寫后就可以用m4程序生成正式的sendmail.cf配置文檔。語法如下: # m4 sendmail.mc sendmail.cf 也可以用源碼目錄樹下的cf/cf/Build命令生成。前提是你要在該目錄下有一個sendmail.mc文檔。語法如下: # ./Build sendmail.cf ok,接著就可以把sendmail.cf and submit.cf文檔安裝到/etc/mail目錄中的,語法如下: # ./Build install-cf 其實也可以自已用cp命令拷貝的啦。記得把sendmail.mc文檔也拷貝一份到/etc/mail目錄,以便以后修改配置時可重新生成sendmail.cf文檔。 ok,接著到/etc/mail目錄下配置一些文檔。 # cd /etc/mail # echo local-host-names 接收郵件的主機名 # echo localhost RELAY access 用來拒絕或允許來自某個域的郵件,本例允許本地轉(zhuǎn)發(fā)。 # makemap hash access access 生成access.db數(shù)據(jù)庫 # touch domaintable 用來把舊域名映射互新域名 # makemap hash domaintable domaintable # touch mailertable 來覆蓋向指定域的路由 # makemap hash mailertable mailertable # touch trusted-users # touch virtusertable 用來把用戶和域名映射到其它地址 # makemap hash virtusertable virtusertable # chown root:wheel /var/spool/mqueue/ # chmod 700 /var/spool/mqueue # touch aliases 別名數(shù)據(jù)庫,文本形式??蓞⒄赵创a目錄樹下 sendmail/aliases文件。 # newaliases 從文本文件中創(chuàng)建一個新的別名數(shù)據(jù)庫文件。 # sendmail -v -bi 調(diào)試啟動。 /etc/mail/aliases: 42 aliases, longest 10 bytes, 432 bytes total 如果出現(xiàn)以上提示信息,則啟動成功。可用以下命令正式啟動: # sendmail -bd -q30m 該命令以后臺進程方式(-bd)運行,并使其每隔30分鐘(-q30m)輪詢一次未發(fā)送郵件隊列,檢查是否有新郵件。 服務(wù)器啟動后,可以用telnet連接服務(wù)器。 # telnet localhost 25 Trying . Connected to localhost. Escape character is . 220 test.tigerhead ESMTP Sendmail 8.12.10/8.12.10; Tue, 30 Mar 2004 14:50:14 +0800 ehlo test 你輸入的命令,按回車結(jié)束。 250-test.tigerhead Hello LOCALHOST.localdomain , pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN 250-DELIVERBY 250 HELP 以250-開頭的為服務(wù)器的響應(yīng)信息。注意倒數(shù)第三行,這就是成功配置smtp驗證的顯示。輸入quit離開。安裝完成后為確保系統(tǒng)安全,還需調(diào)整一些目錄的權(quán)限??蓞⒖約endmail源碼目錄下 sendmail/SECURITY文檔。 # chmod 0640 /etc/mail/aliases /etc/mail/aliases.db,pag,dir # chmod 0640 /etc/mail/*.db,pag,dir # chmod 0640 /etc/mail/statistics /var/log/sendmail.st # chmod 0600 /var/run/sendmail.pid /etc/mail/sendmail.pid -r-xr-sr-x root smmsp . /PATH/TO/sendmail drwxrwx- smmsp smmsp . /var/spool/clientmqueue drwx- root wheel . /var/spool/mqueue -r-r-r- root wheel . /etc/mail/sendmail.cf -r-r-r- root wheel . /etc/mail/submit.cf 6、sendmail功能介紹 aliases 別名數(shù)據(jù)庫設(shè)置 test: test1,test2,test3 設(shè)置test群組別名,test不是一個實際的用戶,只是一個別名。發(fā)給test的信,test1,2,3都可收到。 test: test,testbak 在testbak郵箱中備份test的郵件。 test: test, 遠程郵件備份,原理同上。 test: :include: /etc/mail/userlist 使用用戶列表設(shè)置群組。 userlist格式如下: test1, test2, test3, test4 關(guān)于系統(tǒng)預(yù)設(shè)aliases,由于sendmail預(yù)設(shè)用mailer-daemon and postmaster作為資料傳送者,或郵件退回的帳號,但系統(tǒng)實際沒有這兩個帳號,所以要如下設(shè)置別名。 mailer-daemon: postmaster postmaster: root 設(shè)置完成后不要忘了用newaliases命令生成數(shù)據(jù)庫。 /.forward文件配置 其實該文檔的作用和aliases數(shù)據(jù)庫的作差不多啦,都是配置別名,做郵件轉(zhuǎn)發(fā)的。因為alises只能由管理員控制,個人用戶不能修改,所以就可以在個人的目錄下建立一個轉(zhuǎn)寄文檔。以設(shè)置個人的郵件轉(zhuǎn)寄列表。文檔格式如下: test test1 test2 test3 and os on 但由于個人用戶安全意識差,如果設(shè)置不當會有安全漏洞,不建議使用。 access訪問控制列表設(shè)置 92.168 RELAY test.NET OK test.COM REJECT test.COM 550 SORRY,WE DONT ALLOW SPAMMERS HERE test.ORG DISCARD Ok-遠程主機可以向你的郵件服務(wù)器發(fā)送郵件; RELAY-允許中轉(zhuǎn); REJECT-不能向你的郵件服務(wù)器發(fā)郵件和不能中轉(zhuǎn); DISCARD-發(fā)來的郵件將被丟棄,同時并不向發(fā)送者返回錯誤信息。 nnn text- 發(fā)來的郵件將被丟棄,但sendmail將會向發(fā)送者返回nnn確定的smtp代碼和text變量確定的文本描述。 設(shè)置完成后要用makemap hash access.db access命令生成數(shù)據(jù)庫。 mailq郵件隊列查詢命令。 Q-ID 郵件id號。 Size 郵件容量。 Q-Time 郵件進入隊列(也就是/var/spool/mqueue目錄)的時間和不能郵寄的原因。 Sender/Recipient 發(fā)信和收信人的郵箱地址。 mailstats郵寄狀態(tài)查詢命令,可查詢sendmail運行作至今郵件收發(fā)總計資料。 M : msgsfr:發(fā)送的郵件數(shù)量。 bytes_from:郵件容量 megsto:收到郵件的數(shù)量。 bytes_to:同上 msgsrej:郵件deny的次數(shù)。 msgsdis:郵件discard的次數(shù)。 Mailer :esmtp對外郵件 ,local本地郵件 。 mail郵件命令 mail 查看/var/spool/mail/目錄下自已郵箱內(nèi)容。以q退出把看過的郵件保存在/mbox中。 mail 直接發(fā)郵件給人。 mail -s title text hello.uue default input is stdin;default output is stdout. 解碼:uudecode -o outfile name example:uudecode hello.uue 可以用-o選項輸出另外一個 文件名。 # uuencode /.bashrc bashrc | mail -s test uuencode 在Fedora上建立自己的郵件服務(wù)器一、軟件的準備 A.檢查你的系統(tǒng)是否已安裝了以下軟件1.pam2.pam-devel3.mysql4.mysql-servel5.mysql-devel6.imap-devel7.sharutilsB.下載以下軟件1.metamail*.i386.rpm2.pam-mysql3.cyrus-sasl-2.1.154.postfix-2.0.165.courier-imapC.說明mysql-devel在第3個盤。我忘了裝,結(jié)果pam-mysql和postfix的編譯過不了。metamail和sharutils是取驗證碼用的。二、mysql數(shù)據(jù)庫和表的建立A.rootlocalhost root# mysqlWelcome 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 postfixlocalhost - 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.把下列文字復(fù)制存為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 default12345, gid smallint(5) unsigned NOT NULL default12345, quota varchar(255) NOT NULL default, domain varchar(255) NOT NULL default, create_date date NOT NULL default0000-00-00, create_time time NOT NULL default00:00:00, change_date date NOT NULL default0000-00-00, change_time time NOT NULL default00:00:00, last_access int(10) unsigned NOT NULL default0, passwd_lastchanged int(10) unsigned NOT NULL default0, status tinyint(4) NOT NULL default1, PRIMARY KEY (username), KEY status (status) ) TYPE=MyISAM; #end# rootlocalhost root# mysql postfix 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 是虛擬的郵箱addressdomain.tld ,將被轉(zhuǎn)發(fā)到goto下的聯(lián)結(jié)中. goto 可以用簡單的名字,如果是本地用戶名,如(root, postmaster, etc.), 或者是整個的郵箱名字,userdomain.tld。 Mailbox表的內(nèi)容: Userid 使用者編碼 username 可以是user.domain.tld 或 userdomain.tld password 在mysql中用encrypt(password) 輸入. name 使用著的真實姓名。 uid 虛擬用戶身份uid gid 組的gidhome /usr/local/virtual/. Maildirs必須在此目錄下。 domain 這欄可以不要,但有些軟件需要他。 maildir 是整個地址,必須帶”/”結(jié)尾。Quota 郵箱的空間或信息量的限制。 status 0 為禁止。MYSQL_WHERE_CLAUSE= status. 三、pam-mysql的編譯tar pam-mysql-5.0.tar.gzmake cp pam_mysql.so /lib/security四、修改pam rootlocalhostpam_mysql#cd/etc/pam.drootlocalhostpam.d#cp/work/postfixpostfixrootlocalhostpam.d#postfix的內(nèi)容如下:#/etc/pam.d/postfix#echoauthsufficientpam_mysql.souser=postfixpasswd=postfixhost=localhostdb=postfixtable=mailboxusercolumn=usernamepasswdcolumn=passwordcrypt=1echoaccountrequiredpam_mysql.souser=postfixpasswd=postfixhost=localhostdb=postfixtable=mailboxusercolumn=usernamepasswdcolumn=passwordcrypt=1echoauthsufficientpam_unix_auth.soechoaccountsufficientpam_unix_acct.sorootlocalhostpam.d#-fimap&mvimapimap.origrootlocalhostpam.d#-fpop&mvpoppop.origrootlocalhostpam.d#-fsmtp&mvsmtpsmtp.origrootlocalhostpam.d#n-spostfiximapbash:n:commandnotfoundrootlocalhostpam.d#ln-spostfiximaprootlocalhostpam.d#ln-spostfixpoprootlocalhostpam.d#ln-spostfixsmtprootlocalhostpam.d#cppostfixsieverootlocalhostpam.d#cd. 五、cyrus-sasl的安裝配置我本不想重新編譯cyrus-sasl的,可是fedora自帶的在我測試的時候出問題,還是重編譯吧,雖然fedora帶的也是2.1.15版本。rootlocalhost etc# cd /ruanjian rootlocalhost ruanjian# cd cyrus-sasl-2.1.15 rootlocalhost cyrus-sasl-2.1.15# ./configure -disable-sample -disable-pwcheck -disable-gssapi -disable-cram -disable-digest -disable-krb4 -disable-anon -with-saslauthd=/var/run/saslauthd -enable-plain -enable-login rootlocalhost cyrus-sasl-2.1.15# -d /usr/lib/sasl2 & mv /usr/lib/sasl2 /usr/lib/sasl2.orig rootlocalhost cyrus-sasl-2.1.15# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2 rootlocalhost cyrus-sasl-2.1.15# echo /usr/local/lib /etc/ld.so.conf rootlocalhost cyrus-sasl-2.1.15# echo /usr/local/lib/sasl2 /etc/ld.so.conf rootlocalhost cyrus-sasl-2.1.15# ldconfig rootlocalhost cyrus-sasl-2.1.15# rootlocalhost cyrus-sasl-2.1.15# echo pwcheck_method: saslauthd /usr/lib/sasl2/smtpd.conf rootlocalhost cyrus-sasl-2.1.15# /usr/local/sbin/saslauthd -a pam rootlocalhost cyrus-sasl-2.1.15# 六、postfix的安裝和配置A.先停止sendmail.fedora已經(jīng)默認安裝了sendmail,去掉它。rootlocalhost ruanjian# /etc/init.d/sendmail stop 關(guān)閉 sendmail:失敗 rootlocalhost ruanjian# mv /usr/bin/newaliases /usr/bin/newaliases.orig rootlocalhost ruanjian#mv /usr/bin/mailq /usr/bin/mailq.orig rootlocalhost ruanjian# mv /usr/sbin/sendmail /usr/sbin/sendmail.orig B.添加用戶和組rootlocalhost ruanjian# groupadd -g 12345 postfix rootlocalhost ruanjian# groupadd -g 12346 postdrop rootlocalhost ruanjian# useradd -u 12345 -g 12345 -c postfix -d /dev/null -s /nologin postfix C.編譯postfixrootmail ruanjian# cd postfix-2.0.16 rootmail postfix-2.0.16# make -f Makefile.init makefiles CCARGS=-DUSE_SASL_AUTH -DHAS_MYSQL -I/usr/include/mysql -I/usr/include/sasl AUXLIBS=-L/usr/lib/mysql -L/usr/local/lib/sasl2 -lmysqlclient -lsasl2 -lz -lm rootmail postfix-2.0.16# make install rootlocalhost postfix-2.0.16# cd /etc rootlocalhost etc# mv aliases aliases.orig rootlocalhost etc# ln -s postfix/aliases aliases rootlocalhost etc# cd postfix rootlocalhost postfix# echo root: tester /etc/postfix/aliases rootlocalhost postfix# postalias /etc/postfix/aliases rootlocalhost postfix# D.配置postfix. 1. 主要是main.cf的配置。 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_gid_maps = static:12345 virtual_mailbox_base = /usr/local/virtual v

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論