设为首页 收藏本站
查看: 968|回复: 0

[经验分享] RedHat 5.4+ Postfix +Extmail实现基于虚拟用户的邮件系统(一)

[复制链接]

尚未签到

发表于 2018-5-12 08:41:50 | 显示全部楼层 |阅读模式
一、系统环境

1、Extmail架构  
DSC0000.png

                                         
2、拓朴图
                                                     


DSC0001.png


  

  

服务器

客户端

RedHat 5.4

mail.postfix.org

172.16.1.254

172.16.1.10



所软件包:
postfix-2.8.6.tar.gz
extman-1.1.tar.gz
extmail-1.2.tar.gz
courier-authlib-0.63.0.tar.bz2
Unix-Syslog-1.1.tar.gz
Time-HiRes-1.9725.tar.gz
File-Tail-0.99.3.tar.gz
rrdtool-1.4.7.tar.gz
二、基本配置
1、配置IP
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=172.16.1.254
NETMASK=255.255.255.0
:wq
[root@localhost ~]# service network restart

2、配置DNS文件
[root@mail ~]# vim /etc/resolv.conf
nameserver 172.16.1.254

3、配置hosts文件
[root@mail ~]# vim /etc/hosts  
127.0.0.1       localhost.localdomain localhost
172.16.1.254    mail.postfix.org

4、配置主机名:mail.postfix.org
[root@localhost ~]# vim /etc/sysconfig/network
HOSTNAME=mail.postfix.org
:wq  保存
[root@localhost ~]# hostname mail.postfix.org
断开终端,再次连接,这样就需要重新启动系统:ctrl+d
[root@mail ~]# hostname
mail.postfix.org

5SELinux关闭、LINUX关闭防火墙
SELinux关闭
1 永久方法 需要重启服务器
修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。
2 临时方法 设置系统参数
使用命令setenforce 0

LINUX关闭防火墙
1 重启后永久性生效:
开启:chkconfig iptables on
关闭:chkconfig iptables off
2 即时生效,重启后失效:
开启:service iptables start
关闭:service iptables stop

三、配置YUM()
参考方案:http://yanghuawu.blog.51cto.com/2638960/886129
挂载光盘:本次挂载目录:/mnt
[root@mail ~]# mount -i /dev/cdrom /mnt

四、安装bind(DNS)
[root@mail ~]# yum install bind bind-chroot caching-nameserver
[root@mail ~]# cd /var/named/chroot/etc/
[root@mail etc]# ll
total 32
-rw-r--r-- 1 root root   405 Dec 18 09:17 localtime
-rw-r----- 1 root named 1230 Jul 30  2009 named.caching-nameserver.conf
-rw-r----- 1 root named  955 Jul 30  2009 named.rfc1912.zones
-rw-r----- 1 root named  113 Dec 18 14:30 rndc.key
[root@mail etc]# cp -p named.caching-nameserver.conf named.conf
[root@mail etc]# cp named.conf named.confbak  #备份
[root@mail etc]# vim named.conf
修改:
行数
15         listen-on port 53 { any; };
27         allow-query     { any; };
28         allow-query-cache { any; };
37         match-clients      { any; };
38         match-destinations { any; };

:wq
[root@mail etc]# cd named.rfc1912.zones named.rfc1912.zonesbak #备份
[root@mail etc]# vim named.rfc1912.zones  
复制修改以下内容:
21 zone "localhost" IN {
22         type master;
23         file "localhost.zone";
24         allow-update { none; };
25 };
修改如下:
27 zone "postfix.org" IN {
28         type master;
29         file "postfix.org.zone";
30         allow-update { none; };
31 };

:wq
[root@mail etc]# cd ../var/named/
[root@mail named]# pwd
/var/named/chroot/var/named
[root@mail named]# cp -p localhost.zone postfix.org.zone
[root@mail named]# cp postfix.org.zone postfix.org.zonebak   #备份
[root@mail named]# vim postfix.org.zone
$TTL    86400
@               IN SOA  ns.postfix.org.    root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

                IN NS           ns.postfix.org.
ns              IN A            172.16.1.254
mail            IN A            172.16.1.254
pop3            IN CNAME        mail
smtp            IN CNAME        mail
@               IN MX 10        mail

:wq

[root@mail named]# service named restart
[root@mail named]# chkconfig named on
[root@mail named]# rndc reload
server reload successful
[root@mail named]# dig -t mx postfix.org
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t mx postfix.org
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 663
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; QUESTION SECTION:
;postfix.org.                   IN      MX

;; ANSWER SECTION:
postfix.org.            86400   IN      MX      10 mail.postfix.org.

;; AUTHORITY SECTION:
postfix.org.            86400   IN      NS      ns.postfix.org.

;; ADDITIONAL SECTION:
mail.postfix.org.       86400   IN      A       172.16.1.254
ns.postfix.org.         86400   IN      A       172.16.1.254

;; Query time: 5 msec
;; SERVER: 172.16.1.254#53(172.16.1.254)
;; WHEN: Thu Dec 27 09:24:26 2012
;; MSG SIZE  rcvd: 99
五、关闭sendmail,并不随机启动或者卸载
[root@mail named]# service sendmail status
sendmail (pid  2754) is running...
[root@mail named]# service sendmail stop
[root@mail named]# chkconfig sendmail off

六、安装所需依赖rpm
yum install -y httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect db* cyrus*

七、检查以上开发所有用到的RPM包组是否启动安装
[root@mail named]# yum grouplist  
   Development Libraries        开发言库
   Development Tools           开发工具
   Legacy Software Development  传统软件开发
   X Software Development       图形开发组


方法安装:
[root@mail named]# yum groupinstall &quot;FTP Server&quot;

八、启动mysql数据库,并给mysqlroot用户设置密码
[root@mail named]# service mysqld start
[root@mail named]# chkconfig mysqld on
[root@mail named]# mysqladmin -u root password 'redhat'    #mysql的用户设置密码:redhat
或也可以以下操作:
---------------------------------授权本地用户
[root@mail named]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> set password for root@'localhost'=password('redhat');
Query OK, 0 rows affected (0.00 sec)

mysql> set password for root@'127.0.0.1'=password('redhat');
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
---------------------------------------------授权远程用户
mysql> grant all privileges on *.* to root@'%' identified by 'redhat';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> \q


九、安装postfix
1、创建postfix的执行用户postfix和属组postfix
[root@mail ~]# groupadd -g 2525 postfix
[root@mail ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root@mail ~]# groupadd -g 2526 postdrop
[root@mail ~]# useradd -g postdrop -u 2526 -s /bin/false -M postdrop
2、编译、安装postfix
[root@mail ~]# tar -zxvf postfix-2.8.6.tar.gz -C /usr/local/src/
[root@mail ~]# cd /usr/local/src/
[root@mail src]# cd postfix-2.8.6/
[root@mail postfix-2.8.6]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto' makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl  -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto'
[root@mail postfix-2.8.6]# make
[root@mail postfix-2.8.6]# make install
如下配置:
install_root: [/]
tempdir: [/usr/local/src/postfix-2.8.6] /tmp
config_directory: [/etc/postfix]
command_directory: [/usr/sbin]
daemon_directory: [/usr/libexec/postfix]
data_directory: [/var/lib/postfix]
html_directory: [no]
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq]
manpage_directory: [/usr/local/man]
newaliases_path: [/usr/bin/newaliases]
queue_directory: [/var/spool/postfix]
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail]
setgid_group: [postdrop]


3、生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低
newaliases_path: [/usr/bin/newaliases]
[root@mail postfix-2.8.6]# newaliases
[root@mail postfix-2.8.6]# postfix start  #启动postfix
[root@mail postfix-2.8.6]# netstat -anp |grep :25# netstat -tupln |less
tcp    0    0 0.0.0.0:25     0.0.0.0:*    LISTEN  13280/master

[root@mail postfix-2.8.6]# postconf -m    #模块 mysql
btree
cidr
environ
hash
internal
mysql
nis
proxy
regexp
static
tcp
texthash
unix

实现用service 服务名 start 启动服务!
源代码没有控制同步,可借助于rpm包的控制同步
[root@mail postfix-2.8.6]# mkdir /tmp/abc
[root@mail postfix-2.8.6]# cd /tmp/abc/
[root@mail abc]# cp /mnt/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[root@mail abc]# ll
total 3656
-r--r--r-- 1 root root 3734257 Dec 18 17:31 postfix-2.3.3-2.1.el5_2.i386.rpm
[root@mail abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
[root@mail abc]# ll
total 3680
drwxr-xr-x 5 root root    4096 Dec 18 17:32 etc
-r--r--r-- 1 root root 3734257 Dec 18 17:31 postfix-2.3.3-2.1.el5_2.i386.rpm
drwxr-xr-x 7 root root    4096 Dec 18 17:32 usr
drwxr-xr-x 3 root root    4096 Dec 18 17:32 var
[root@mail abc]# cd etc/
[root@mail etc]# ll
total 24
drwxr-xr-x 2 root root 4096 Dec 18 17:32 pam.d
drwxr-xr-x 2 root root 4096 Dec 18 17:32 postfix
drwxr-xr-x 3 root root 4096 Dec 18 17:32 rc.d
[root@mail etc]# cd rc.d/
[root@mail rc.d]# ll
total 8
drwxr-xr-x 2 root root 4096 Dec 18 17:32 init.d
[root@mail rc.d]# cd init.d/
[root@mail init.d]# ll
total 8
-rwxr-xr-x 1 root root 2404 Dec 18 17:32 postfix
[root@mail init.d]# cp postfix /etc/init.d/
[root@mail init.d]# vim /etc/init.d/postfix   #查看代码,不用编辑()
[root@mail init.d]# service postfix stop
[root@mail init.d]# netstat -tupln |grep 25
tcp        0      0 172.16.1.253:53             0.0.0.0:*                   LISTEN      3486/named         
udp        0      0 172.16.1.253:53             0.0.0.0:*                               3486/named  

[root@mail init.d]# service postfix start
[root@mail init.d]# netstat -tupln |grep 25
tcp        0      0 172.16.1.253:53             0.0.0.0:*                   LISTEN      3486/named         
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      13429/master       
udp        0      0 172.16.1.253:53             0.0.0.0:*                               3486/named         
[root@mail init.d]# chkconfig postfix on # chkconfig --add postfix   #相同
[root@mail init.d]# chkconfig --list |grep postfix
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off

4、创建账号
[root@mail init.d]# useradd user1

5、发邮件测试
[root@mail init.d]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.postfix.org ESMTP Postfix
HELO mail.postfix.org
250 mail.postfix.org
mail from:root@localhost
250 2.1.0 Ok
rcpt to:user1@localhost
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
11111111111111111111111111111
.
250 2.0.0 Ok: queued as 48ABCE72F3
quit
221 2.0.0 Bye
Connection closed by foreign host.


6、查看邮件日志
[root@mail ~]# tail -f /var/log/maillog # tail /var/log/maillog
邮件发送成功!


                                                                       首页|下一页

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-458941-1-1.html 上篇帖子: Redhat 5.4搭建 DNS服务器解析负载 下篇帖子: RedHat 5.4+ Postfix +Extmail实现基于虚拟用户的邮件系统(二)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表