SMTP服务器安装及配置

在配置之前需要将IP地址进行正反向解析,解析生效后才能用于发邮件

  1. 配置网络

       更改Linux的IP地址 :

 vim /etc/sysconfig/network-scripts/ifcfg-eth0

 添加多个IP地址:

 vim ifcfg-eth0-range0  (IP range)

     2. 配置文件

 IPADDR_START=64.151.120.67

 IPADDR_END=64.151.120.76

 ONBOOT=yes

 CLONENUM_START=0

 PREFIX=26

  1. 安装postfix

yum -y install postfix

安装完成还需要替换系统自带的sendmailrpm -e sendmail或者yum remove sendmail

修改MTA(默认邮件传输代理):alternatives --config mta

3安装Dovecot

yum -y install dovecot

4配置Postfix

vi /etc/postfix/main.cf

       在配置文件底部添加如下信息:

     multi_instance_wrapper = ${command_directory}/postmulti -p --

multi_instance_enable = yes

multi_instance_name = postfix-gg1-87072

multi_instance_group = gg1

master_service_disable =

authorized_submit_users = root

myhostname = smtp87072.rsgog.com –解析到主postfix IP

mydomain = rsgog.com

myorigin = $mydomain

mynetworks = 204.51.220.72/32, 127.0.0.0/8

relay_domains = $mydestination

smtp_bind_address = 204.51.220.72

smtpd_sasl_auth_enable = yes

broken_sasl_auth_clients = yes

smtpd_sasl_type = dovecot

smtpd_sasl_path = /var/spool/postfix/private/auth

smtpd_sasl_security_options = noanonymous

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,reject_unauth_destination

修改好了之后使用service postfix start开启postfix,使用chkconfig postfix onpostfix开机启动。

5、配置Dovecot

       vim  /etc/dovecot/dovecot.conf,在配置文件末尾处添加:

      auth_mechanisms = plain login

mbox_write_locks = fcntl

passdb {

  driver = pam

}

service auth {

  unix_listener /var/spool/postfix/private/auth {

    group = postfix

    mode = 0660

    user = postfix

  }

  user = root

}

ssl_cert =

ssl_key =

userdb {

  driver = passwd

}

保存并退出,执行service dovecot start使用chkconfig dovecot ondovecot开机启动。

6从另一台已配置好的机器上拷贝 Programs,Scripts,chk_service.sh文件夹到/root路径下。使用以下语句进行复制:

scp –n(使用n可以复制文件夹) root@另一台机的IP地址:/root/Programs(文件路径) /root(本机存储路径)

回车后会提示输入密码,输入另一台机的密码即可。

更改perfcheck.sh文件的执行权限, cd /Programs

Chmod 744 perfcheck.sh

然后根据平台更改perfCheck.properties 中的intrawebservice的链接以及APIKey

APP平台可以参照 103.230.32.253的设置

DiskPath=/var/spool

IntraServiceURL=http://iws.reasonablespread.com/service.asmx?wsdl

#IntraServiceURL=http://office.reasonable.hk/service.asmx?wsdl

IntraServiceNamespace=http://tempuri.org/

IntraServiceMethod=UpdateServerStatusRPC

IntraServiceAPIKey=77841b4f-f1f8-4c19-b913-c4f322a74dd2

SMTPCommand=/usr/bin/env perl /root/Programs/count_queue.pl

APP1平台可以参照103.230.32.254的设置

DiskPath=/var/spool

#IntraServiceURL=http://iws.reasonablespread.com/service.asmx?wsdl

#IntraServiceURL=http://newintra.reasonables.com/service.asmx?wsdl

IntraServiceURL=http://newiws1.rspread.com/service.asmx?wsdl

#IntraServiceURL=http://office.reasonable.hk/service.asmx?wsdl

IntraServiceNamespace=http://tempuri.org/

IntraServiceMethod=UpdateServerStatusRPC

IntraServiceAPIKey=87841b4f-f1f8-4c19-b913-c4f322a74dd3

SMTPCommand=/usr/bin/env perl /root/Programs/count_queue.pl

APP2平台可以参照 203.186.75.251的设置

DiskPath=/var/spool

IntraServiceURL=http://iws2.rspread.com/service.asmx?wsdl

#IntraServiceURL=http://office.reasonable.hk/service.asmx?wsdl

IntraServiceNamespace=http://tempuri.org/

IntraServiceMethod=UpdateServerStatusRPC

IntraServiceAPIKey=676A0EA4-3DD2-4F7D-B439-C5AB9A4133E3

SMTPCommand=/usr/bin/env perl /root/Programs/count_queue.pl

7、新建postfix实例

       Cd /root/Scripts/POSTFIXMulti更改所有文件的权限:chomd 744 *

Vim createInstance.sh,将里面除第一个POSTFIX实例的记录以外的其他记录都删掉,只保留第一个。更改ID,IP及域名

 

编辑好后,保存并退出。执行 postmulti –e init, 然后执行./createInstance.sh文件,创建一个ID为所编辑的ID的实例。这样做的目的是为了数据库可以根据ID来读取这台机器上的对例信息及更新时间。

8、安装javajdk

yum -y install java-1.7.0-openjdk

设置定时更新:

vim /etc/crontab更改配置文件如下:

[email protected]

1 * * * * /root/Programs/perfCheck.sh > /dev/null

31 * * * * /root/Programs/perfCheck.sh > /dev/null

1 * * * * /root/chk_service.sh > /dev/null

31 * * * * /root/chk_service.sh > /dev/null

将chk_service.sh上传到root目录,并且更改权限为744

9、添加postfix多实例

        cd /root/Script/POSTFIXMulit

cp addPostfixInstance.sh    addPostfixInstance1.sh

Vim addPostfixInstance1.sh,更改里面的配置,前面带有$的都得进行修改

./ addPostfixInstance1.sh  如果不能运行,试试/bin/bash addPostfixInstance1.sh

Cd /etc  查看是否已经生成了新实例

Postfix start将所有新建的postfix启动

10.新建用户进行测试

# 创建用户
useradd spreadadmin
#设置密码,会要求输入两次密码
passwd spreadadmin

新建好后使用smtptesttool测试,下载地址:

http://smtp-test-tool.software.informer.com/download/

注:如测试时链接不上,可能是8025端口未开启,使用下面语句添加:

       iptables -I INPUT -p tcp --dport 8025 –jACCEPT

update 20160411

执行service iptables save

不然重启防火墙之后配置会失效。

service iptables save  //保存

service iptables restart //重启防火墙

你可能感兴趣的:(SMTP服务器安装及配置)