linux配置mail server 一、配置yum安裝工具① 進入yum目錄 [root@bj ~]# cd /etc/yum.repos.d ② 配置yum.repo [root@bj yum.repos.d]# cprhel-debuginfo.repo yum.repo 將yum.repo修改成以下內容 [root@bj yum.repos.d]# cat yum.repo [Base] name=Red Hat Enterprise Linux baseurl=file:///media/Server enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ③ 把光碟片掛載到/media目錄上 [root@bj ~]# mount /dev/cdrom /media/ 二、通過yum安裝sendmail、dovecot[root@bj ~]# yum install -y sendmail* ----sendmail 負責發送郵件(smtp 協議 ,port 25) [root@bj ~]# yum install -y dovecot* ----dovecot 負責內送郵件(pop3 協議,port 110,imap 協議 ,port 143) 三、配置sendmail① cd /etc/mail m4 sendmail.cf > sendmail.mc ② vi sendmail.mc ----尋找127.0.0.1,將其改為0.0.0.0(預設sendmail只負責發送本地郵件,0.0.0.0將監聽任何地址的郵件) ③ 啟動sendmail服務 1、修改/etc/hosts 192.168.6.130 bj.siqian.com (主機名稱設為主機名稱.網域名稱的方式,否則收不到郵件) 2、修改/etc/sysconfig/network hostname=bj.siqian.com 3、然後再執行 hostname bj.siqian.com 4、啟動sendmail service sendmail start 5、查看smtp [root@bj ~]# netstat -an | grep :25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN ④ 配置郵件接收 [root@bj ~]# vi /etc/dovecot.conf 把其中的: #protocols = imap pop3 lmtp ----取消注釋,改為 protocols = imap pop3 lmtp ⑤ 啟動dovecot服務 service dovecotstart -----查看 pop3,imap [root@bj ~]# netstat -an | grep :110 tcp 0 0 :::110 :::* LISTEN 四、收發郵件①寫郵件,發送郵件 [root@bj ~]# mail -s "oracle"oracle test mail for oracle!!! Cc: root 抄送功能為快速鍵ctl+d ②內送郵件 [root@bj ~]# mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/root": 5messages 5 new >N 1 logwatch@localhost.l Thu Feb 2119:21 43/1563 "Logwatch for node1 (Linux)" N 2logwatch@localhost.l Fri Feb 2213:08 93/2804 "Logwatch for node1 (Linux)" N 3logwatch@bj.siqian.com Mon Jul 1515:08 95/2901 "Logwatch for bj (Linux)" N 4logwatch@bj.siqian.com Mon Jul 1515:32 54/1936 "Logwatch for bj.siqian.com(Linux)" N 5root@bj.siqian.com Mon Jul 1516:21 17/557 "oracle" & 5 Message 5: From root@bj.siqian.com Mon Jul 15 16:21:14 2013 Date: Mon, 15 Jul 2013 16:21:14 +0800 From: root <root@bj.siqian.com> To: oracle@bj.siqian.com Subject: oracle Cc: root@bj.siqian.com test mail for oracle!!! 再換oracle使用者查看郵件 [root@bj mqueue]# su - oracle [oracle@bj ~]$ mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/oracle": 1message 1 new >N 1 root@bj.siqian.com Mon Jul15 16:21 17/557 "oracle" & 1 Message 1: From root@bj.siqian.com Mon Jul 15 16:21:14 2013 Date: Mon, 15 Jul 2013 16:21:14 +0800 From: root <root@bj.siqian.com> To: oracle@bj.siqian.com Subject: oracle Cc: root@bj.siqian.com test mail for oracle!!!