当前位置: > CentOS > CentOS服务器 > 环境配置 >

CentOS 6、7下配置exim发邮件服务器

时间:2016-02-27 13:42来源:blog.51cto.com 作者:IT
1. 配置epel源(exim包位于EPEL软件源中)

CentOS7

  1. # cat > /etc/yum.repos.d/epel.repo << EOF
    [epel]
    name=Extra Packages for Enterprise Linux 7 - \$basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=0
    EOF

CentOS6

  1. # cat > /etc/yum.repos.d/epel.repo << EOF
    [epel]
    name=Extra Packages for Enterprise Linux 6 - \$basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=0
    EOF

2. 禁止postfix

  1. # service postfix stop

  2. # chkconfig postfix off

3. 安装exim

  1. # yum -y install exim

4. 将exim设为默认的MTA

  1. # alternatives --set mta /usr/sbin/sendmail.exim

5. 修改exim配置文件

  1. # vi /etc/exim/exim.conf #几个参数
    primary_hostname = mail.flying.com #查看源邮件时显示Received: from mail.flying.com,如果不指定直接取操作系统的hostname
    domainlist local_domains = @ localhost : localhost.localdomain :mail.flying.com
    domainlist relay_to_domains = flying.com #允许通过改主机发送邮件的域名
    hostlist   relay_from_hosts = 127.0.0.1 192_32G 10.168.0.0/16 :
  2.  
    <br>
  3.  #允许那些客户端主机发送邮件,如本地使用这台服务器发送邮件时,即需要添加本地出口ip地址(公网地址)

6. 测试

  1. # yum -y install mailx

  2. # date | mail -r no-reply@flying.com -s 'exim test' uttflying@foxmail.com 

  3. # tail -f /var/log/exim/main.log #exim日志文件

ps:

如果不指定-r(发邮件地址),且你的主机名不是xxx.com,可能会报如下错误:

SMTP error from remote mail server after MAIL FROM:

错误是550 MI:IMF 发信人电子邮件地址不合规范

 

使用文件进行邮件发送:

 date | mail -r flying@yflying.com -s  'SN_IP info  TEXT ' uttflying@163.com wanglei@flying.com < /root/cobbler/sn.log
 
 
 
 
 mail命令的语法如下:
 Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

测试成功




(责任编辑:IT)
------分隔线----------------------------