亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )

瀏覽:74日期:2024-07-10 18:56:26

前言

在CentOS中,默認(rèn)的郵件服務(wù)器(SMTP方面)是sendmail,但sendmail有若干的缺點,比如,配置復(fù)雜、安全漏洞曾被多次發(fā)現(xiàn)--并且依然存在隱患、郵件發(fā)送速度慢等等,這里就不再一一敘述。而另一個被廣泛應(yīng)用于郵件服務(wù)方面的“Postfix”的缺點就少得多,或者說它就是針對于sendmail的缺點,而被設(shè)計的。對應(yīng)sendmail的短處,它在各方面也比較成熟。所以,無特殊要求,這里不推薦用sendmail來構(gòu)建郵件服務(wù)器。本站介紹的郵件服務(wù)器配置方法,也將基于Postfix。

添加MX記錄(這里假設(shè)使用動態(tài)域名)

由于MX記錄添加后,可能生效要等待一段時間(通常為數(shù)分鐘或數(shù)十分鐘,也可能馬上生效),所以在安裝配置前,我們首先為動態(tài)域名添加MX記錄。添加方法也會因域名ISP的不同而不同,但大致信息如下:

mx mail.centospub.com. 10a mail 服務(wù)器的IP地址

mail為別名,10為優(yōu)先度。這個別名指向服務(wù)器的IP地址。(如有疑問或需要幫忙請到 技術(shù)論壇 發(fā)貼。)

確認(rèn)MX記錄的添加是否生效的方法:

[root@sample ~]# host -t mx centospub.com

centospub.com mail is handled by 10 mail.centospub.com.  ← 確認(rèn)MX記錄生效

安裝Postfix

然后,安裝Postfix。

[root@sample ~]# yum -y install postfix  ← 在線安裝Postfix

Setting up Install ProcessSetting up repositoriesdag 100% |=========================| 1.1 kB 00:00update 100% |=========================| 951 B 00:00base 100% |=========================| 1.1 kB 00:00addons 100% |=========================| 951 B 00:00extras 100% |=========================| 1.1 kB 00:00Reading repository metadata in from local filesprimary.xml.gz 100% |=========================| 28 kB 00:04update : ################################################## 84/84Added 84 new packages, deleted 1499 old in 3.44 secondsprimary.xml.gz 100% |=========================| 157 B 00:00Added 0 new packages, deleted 1499 old in 1.97 secondsprimary.xml.gz 100% |=========================| 26 kB 00:00extras : ################################################## 102/102Added 102 new packages, deleted 1499 old in 2.73 secondsReducing Dag RPM Repository for Red Hat Enterprise Linux to included packages onlyFinishedParsing package install argumentsResolving Dependencies--> Populating transaction set with selected packages. Please wait.---> Downloading header for postfix to pack into transaction set.postfix-2.2.10-1.RHEL4.2. 100% |=========================| 40 kB 00:00---> Package postfix.i386 2:2.2.10-1.RHEL4.2 set to be updated--> Running transaction checkDependencies Resolved

=============================================================================Package Arch Version Repository Size=============================================================================Installing:postfix i386 2:2.2.10-1.RHEL4.2 base 3.0 M

Transaction Summary=============================================================================Install 1 Package(s)Update 0 Package(s)Remove 0 Package(s)Total download size: 3.0 MDownloading Packages:(1/1): postfix-2.2.10-1.R 100% |=========================| 3.0 MB 00:05Running Transaction TestFinished Transaction TestTransaction Test SucceededRunning TransactionInstalling: postfix ######################### [1/1]

Installed: postfix.i386 2:2.2.10-1.RHEL4.2Complete!

配置Postfix及相關(guān)組件

[1] 對Postfix進行配置。

[root@sample ~]# vi /etc/postfix/main.cf  ← 編輯Postfix的配置文件

#myhostname = host.domain.tld  ← 找到此行,將等號后面的部分改寫為主機名↓myhostname = sample.centospub.com  ← 變?yōu)榇藸顟B(tài),設(shè)置系統(tǒng)的主機名

#mydomain = domain.tld  ← 找到此行,將等號后面的部分改寫為域名↓mydomain = centospub.com  ← 變?yōu)榇藸顟B(tài),設(shè)置域名(我們將讓此處設(shè)置將成為E-mail地址“@”后面的部分)

#myorigin = $mydomain  ← 找到此行,將行首的#去掉↓myorigin = $mydomain  ← 變?yōu)榇藸顟B(tài),將發(fā)信地址“@”后面的部分設(shè)置為域名(非系統(tǒng)主機名)

inet_interfaces = localhost  ← 找到此行,將“l(fā)ocalhost”改為“all”↓inet_interfaces = all  ← 變?yōu)榇藸顟B(tài),接受來自所有網(wǎng)絡(luò)的請求

mydestination = $myhostname, localhost.$mydomain, localhost  ← 找到此行,在行為添加“$mydomain”↓mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  ← 變?yōu)榇藸顟B(tài),指定發(fā)給本地郵件的域名

#relay_domains = $mydestination  ← 找到此行,將行首的#去掉↓relay_domains = $mydestination  ← 變?yōu)榇藸顟B(tài),定義允許轉(zhuǎn)發(fā)的域名

#mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 找到此行,依照自己的內(nèi)網(wǎng)情況修改↓mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 變?yōu)榇藸顟B(tài),指定內(nèi)網(wǎng)和本地的IP地址范圍

#home_mailbox = Maildir/  ← 找到這一行,去掉行首的#↓home_mailbox = Maildir/  ← 變?yōu)榇藸顟B(tài),指定用戶郵箱目錄

# SHOW SOFTWARE VERSION OR NOT## The smtpd_banner parameter specifies the text that follows the 220# code in the SMTP server’s greeting banner. Some people like to see# the mail version advertised. By default, Postfix shows no version.## You MUST specify $myhostname at the start of the text. That is an# RFC requirement. Postfix itself does not care.##smtpd_banner = $myhostname ESMTP $mail_name#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  ← 找到這一行,接此行添加如下行:smtpd_banner = $myhostname ESMTP unknow  ← 添加這一行,不顯示SMTP服務(wù)器的相關(guān)信息

在配置文件的文尾,添加如下行:

smtpd_sasl_auth_enable = yes  ← 服務(wù)器使用SMTP認(rèn)證smtpd_sasl_local_domain = $myhostname  ← 指定SMTP認(rèn)證的本地域名(主機名)smtpd_sasl_security_options = noanonymous   ← 不允許匿名的方式認(rèn)證smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destinationmessage_size_limit = 15728640  ← 規(guī)定郵件最大尺寸為15MB

[2] 配置SMTP認(rèn)證的相關(guān)選項

為了提高安全性,我們不將系統(tǒng)用戶的密碼作為相應(yīng)用戶SMTP認(rèn)證的密碼,而將在后面為用戶建立SMTP認(rèn)證專用的密碼。

[root@sample ~]# vi /usr/lib/sasl2/smtpd.conf  ← 編輯SMTP認(rèn)證的配置文件

pwcheck_method: saslauthd  ← 找到此行,將“saslauthd”改為“auxprop”↓pwcheck_method: auxprop  ← 不使用系統(tǒng)用戶密碼作為用戶的SMTP認(rèn)證密碼

[root@sample ~]# vi /etc/sysconfig/saslauthd

MECH=shadow  ← 找到這一行,在前面加#↓#MECH=shadow  ← 不使用shadow機制

FLAGS=  ← 找到此行,在等號后面添加“sasldb”↓FLAGS=sasldb   ← 定義認(rèn)證方式為sasldb2

[3] 建立用戶的郵箱目錄

首先建立用戶模板下的郵箱目錄,以便于建立新用戶時,相應(yīng)用戶的郵箱目錄自動被建立。

[root@sample ~]# mkdir /etc/skel/Maildir  ← 在用戶模板下建立用戶郵箱目錄

[root@sample ~]# chmod 700 /etc/skel/Maildir  ← 設(shè)置用戶郵箱目錄屬性為700

然后再為已經(jīng)存在的用戶建立相應(yīng)郵箱目錄。

[root@sample ~]# mkdir /home/centospub/Maildir  ← 為用戶(這里以centospub用戶為例)建立郵箱目錄

[root@sample ~]# chmod 700 /home/centospub/Maildir  ← 設(shè)置該用戶郵箱目錄屬性為700

[root@sample ~]# chown centospub. /home/centospub/Maildir  ← 設(shè)置該用戶郵箱目錄為該用戶所有

[4] 為用戶設(shè)置SMTP認(rèn)證密碼

[root@sample ~]# saslpasswd2 -u sample.centospub.com -c centospub  ← 為centospub用戶設(shè)置SMTP認(rèn)證密碼

Password:  ← 在這里輸入密碼(不會顯示)Again (for verification):  ← 再次輸入密碼

[5] 改變SALS的屬性及歸屬

[root@sample ~]# chgrp postfix /etc/sasldb2  ← 將數(shù)據(jù)庫歸屬改為postfix,

[root@sample ~]# chmod 640 /etc/sasldb2  ← 將數(shù)據(jù)庫屬性改為640

[6] 關(guān)閉sendmail服務(wù)及設(shè)置默認(rèn)MTA

因為在用Postfix作為SMTP服務(wù)器的前提下,我們不準(zhǔn)備再用sendmail,所以將sendmail服務(wù)關(guān)掉,以確保安全及節(jié)省系統(tǒng)資源。

[root@sample ~]# /etc/rc.d/init.d/sendmail stop  ← 關(guān)閉sendmail服務(wù)

Shutting down sendmail: [ OK ]Shutting down sm-client: [ OK ]

[root@sample ~]# chkconfig sendmail off  ← 關(guān)閉sendmail自啟動

[root@sample ~]# chkconfig --list sendmail  ← 確認(rèn)sendmail自啟動已被關(guān)閉(都為off就OK)sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off

然后再將默認(rèn)的MTA設(shè)置為Postfix。

[root@sample ~]# alternatives --config mta  ← 設(shè)置默認(rèn)MTAThere are 2 programs which provide ’mta’.

Selection Command-----------------------------------------------*+ 1 /usr/sbin/sendmail.sendmail  ← 當(dāng)前狀態(tài):sendmail為默認(rèn)MTA2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number: 2  ← 在這里輸入2,使Postfix成為默認(rèn)MTA

啟動相應(yīng)服務(wù)

最后,啟動SMTP認(rèn)證及Postfix服務(wù),并設(shè)置相應(yīng)服務(wù)為自啟動。

[root@sample ~]# chkconfig saslauthd on  ← 將SMTP-Auth設(shè)置為自啟動

[root@sample ~]# chkconfig --list saslauthd  ← 確認(rèn)SMTP-Auth服務(wù)狀態(tài)saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 確認(rèn)2~5為on的狀態(tài)就OK

[root@sample ~]# /etc/rc.d/init.d/saslauthd start  ← 啟動SMTP-Auth

Starting saslauthd: [ OK ]

[root@sample ~]# chkconfig postfix on  ← 將Postfix設(shè)置為自啟動

[root@sample ~]# chkconfig --list postfix  ← 確認(rèn)Postfix服務(wù)狀態(tài)postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 確認(rèn)2~5為on的狀態(tài)就OK

[root@sample ~]# /etc/rc.d/init.d/postfix start  ← 啟動Postfix

Starting postfix:  [ OK ]

至此,就完成了SMTP服務(wù)器方面的配置,但目前只具從備客戶端通過服務(wù)器發(fā)送郵件的功能。做為完整的郵件服務(wù)器,還需具備從客戶端通過POP/IMAP協(xié)議接受郵件到本地的功能。POP/IMAP服務(wù)器的構(gòu)建請參見下一節(jié) < POP / IMAP 服務(wù)器的構(gòu)建( Dovecot ) >。

標(biāo)簽: CentOS
相關(guān)文章:
主站蜘蛛池模板: 黄色免费观看 | 国产乱人视频在线看 | 久久99精品综合国产首页 | 91久久国产视频 | 一区视频在线播放 | 亚洲图区综合 | 欧美激情视频一区二区免费 | 你懂的最新网址 | 欧美精品在线视频观看 | 中文字幕 日韩在线 | 国产午夜视频在线 | 91精品福利手机国产在线 | 中文字幕亚洲一区二区v@在线 | 99在线视频精品 | 一区二区不卡免费视频 | 黄色三级网站 | 欧美视频在线一区二区三区 | 欧美成人高清手机在线视频 | 亚洲综合99 | www.成人.com | 日韩孕交japanese孕交 | 24小时中文乱码字幕在线观看 | 国产成人综合久久精品亚洲 | 久久亚洲国产精品五月天 | 91短视频网站 | 国产aⅴ精品一区二区三区久久 | 精品毛片| 久久久久香蕉视频 | 综合图区亚洲 | 91精品免费久久久久久久久 | 免费久久一级欧美特大黄 | 国产日韩精品视频一区二区三区 | 国产福利免费在线观看 | 日本aaaa毛片在线看 | 在线观看www成人影院 | 国产一级特黄全黄毛片 | 黄网在线免费 | 日韩亚洲人成在线综合日本 | 国产欧美精品亚洲桃花岛 | 777奇米影视笫四色88me久久综合 | 国产成人免费高清激情视频 |