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 [email protected]  Thu Feb 2119:21  43/1563  "Logwatch for node1 (Linux)"

 N  [email protected]  Fri Feb 2213:08  93/2804  "Logwatch for node1 (Linux)"

 N  [email protected]  Mon Jul 1515:08  95/2901  "Logwatch for bj (Linux)"

 N  [email protected]  Mon Jul 1515:32  54/1936  "Logwatch for bj.siqian.com(Linux)"

 N  [email protected]      Mon Jul 1516:21  17/557   "oracle"

& 5

Message 5:

From [email protected]  Mon Jul 15 16:21:14 2013

Date: Mon, 15 Jul 2013 16:21:14 +0800

From: root <[email protected]>

To: [email protected]

Subject: oracle

Cc: [email protected]

 

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 [email protected]      Mon Jul15 16:21  17/557   "oracle"

& 1

Message 1:

From [email protected]  Mon Jul 15 16:21:14 2013

Date: Mon, 15 Jul 2013 16:21:14 +0800

From: root <[email protected]>

To: [email protected]

Subject: oracle

Cc: [email protected]

 

test mail for oracle!!!

你可能感兴趣的:(server)