郵件服務器(Mail Server)是電子郵件系統的核心,它包括郵件發送服務器(SMTP服務器)和郵件接收服務器(POP3)。郵件服務器的功能是發送和接收郵件,同時還向發送人報告郵件的發送情況。
SMTP:Simple Mail Tansfer Protocol 簡單郵件傳輸協議,它使用傳輸層TCP協議的25端口;
POP3:Post Office Protocol 郵局協議,它使用傳輸層TCP協議的110端口。
一、首先做DNS服務器
1、下載yum源
2、安裝bind包
3、編輯配置文件內容vim /etc/named.conf 內容修改如下:
4、vim /etc/named.rfc1912.zones 添加內容如下
5、編輯完配置文件後檢查是否有語法錯誤
6、cd /var/named
vim wxx.com.zone 編輯配置文件內容如下
7、檢查是否有語法錯誤並關閉selinux
vim /etc/sysconfig/selinux (vim /etc/sysconfig/selinux是vim /etc/selinux/config的鏈接,這兩個路徑將來在很多地方都能看到)
8、修改權限
9、查看53號端口
測試一下
10、vim /etc/resolv.conf 編輯配置文件內容如下
11、編輯配置文件vim /etc/sysconfig/network 改自己的主機名
hostname mail.wxx.com 與主機名保持一致
named已完成,下一步安裝postfix
二、安裝postfix
1、安裝postfix前請確保我們的開發庫都已安裝
2、安裝mysql-server和mysql-devel
3、啓動mysql
chkconfig mysqld on 開啓mysql
4、測試mysql
5、下載安裝mysql
6、創建postfix用戶
groupadd -g 2525 postfix
useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
groupadd -g 2526 postdrop
useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
7、解壓postfix文件並設定系統用戶的時間
crontab -e 編輯內容如下
8、make makefiles
make
make install
9、vim /etc/init.d/postfix 編輯配置文件內容腳本如下:
- #!/bin/bash
- #
- # postfix Postfix Mail Transfer Agent
- #
- # chkconfig: 2345 80 30
- # description: Postfix is a Mail Transport Agent, which is the program \
- # that moves mail from one machine to another.
- # processname: master
- # pidfile: /var/spool/postfix/pid/master.pid
- # config: /etc/postfix/main.cf
- # config: /etc/postfix/master.cf
- # Source function library.
- . /etc/rc.d/init.d/functions
- # Source networking configuration.
- . /etc/sysconfig/network
- # Check that networking is up.
- [ $NETWORKING = "no" ] && exit 3
- [ -x /usr/sbin/postfix ] || exit 4
- [ -d /etc/postfix ] || exit 5
- [ -d /var/spool/postfix ] || exit 6
- RETVAL=0
- prog="postfix"
- start() {
- # Start daemons.
- echo -n $"Starting postfix: "
- /usr/bin/newaliases >/dev/null 2>&1
- /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
- RETVAL=$?
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
- echo
- return $RETVAL
- }
- stop() {
- # Stop daemons.
- echo -n $"Shutting down postfix: "
- /usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
- RETVAL=$?
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
- echo
- return $RETVAL
- }
- reload() {
- echo -n $"Reloading postfix: "
- /usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
- RETVAL=$?
- echo
- return $RETVAL
- }
- abort() {
- /usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
- return $?
- }
- flush() {
- /usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
- return $?
- }
- check() {
- /usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
- return $?
- }
- restart() {
- stop
- start
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- reload)
- reload
- ;;
- abort)
- abort
- ;;
- flush)
- flush
- ;;
- check)
- check
- ;;
- status)
- status master
- ;;
- condrestart)
- [ -f /var/lock/subsys/postfix ] && restart || :
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
- exit 1
- esac
- exit $?
- # END
添加執行權限
10、cd /etc/postfix/
編輯配置文件vim main.cf
11、查看我們新配的項
12、查看日誌信息
發現sendmail忘記關閉不要着急,我們有應對方案
service sendmail stop 先停止sendmail
chkconfig sendmail off 關閉sendmail
13、查看25號端口新建用戶後並測試
useradd hadoop 新建用戶hadoop
useradd openstak 新建用戶openstack
echo "hadoop" | passwd --stdin hadoop 設置密碼同用戶名
ehho "redhat" | passwd --stdin openstack 設置密碼同用戶名
14、查看日誌
三、測試使用windows遠程發送郵件
1、配置OE嘗試發送郵件
2、登錄hadoop用戶給openstack發送一封郵件
3、由於我們現在還沒有收郵件的服務器,所以就在本機上查看內容郵件內容
這樣我們就實現了郵件的收發功能。