Postfix+Sasl+Courier-authlib+Dovecot+MySQL+extmail 邮件系统部署
# yum remove postfix ##删除系统自带postfix
# userdel postfix
# groupdel postdrop
# 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
yum install httpd mysql mysql-server mysql-devel openssl openssl-devel dovecot dovecot-mysql tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect expect-devel gcc gcc-c++ cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel telnet libicu-devel -y
安装postfix
wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-3.0.2.tar.gz
tar xf postfix-3.0.2.tar.gz
cd postfix-3.0.2
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto'
make
make install
Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix]
Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq]
Please specify the final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man]
Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases]
Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix]
Please specify the final destination directory for the Postfix README
files. Specify "no" if you do not want to install these files.
readme_directory: [no]
Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail]
Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is
not shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop]
[root@ipython ~]# newaliases #生成别名文件
[root@ipython ~]# ll /etc/aliases.db
-rw-r--r-- 1 root root 12288 Jul 8 13:24 /etc/aliases.db
测试邮件发送
[root@ipython postfix]# telnet localhost
Trying ::...
telnet: connect to address ::: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
ipython.localdomain ESMTP Postfix
ehlo localhost
-ipython.localdomain
-PIPELINING
-SIZE
-VRFY
-ETRN
-ENHANCEDSTATUSCODES
-8BITMIME
DSN
mail from:root@localhost
2.1. Ok
rcpt to:deo@localhost
2.1. Ok
data
End data with <CR><LF>.<CR><LF>
Subject:hello test
.
2.0. Ok: queued as AF46E2615D4
quit
2.0. Bye
Connection closed by foreign host.
部署dns
[root@mail ~]# yum install bind bind-utils -y
[root@mail ~]# hostname
mail.deo.com
# vi /etc/named.conf
# listen-on port { 127.0.0.1; };
# listen-on-v6 port { ::; }; ##注释或删除以上两行 [root@mail ~]# cat /etc/named.rfc1912.zones #到最后添加如下内容 zone "deo.com" IN {
type master;
file "deo.com.zone";
allow-update { none; };
allow-transfer { none; };
}; zone "80.16.172.in-addr.arpa" IN {
type master;
file "172.16.80.zone";
allow-update { none; };
allow-transfer { none; };
}; [root@mail ~]# named-checkconf /etc/named.conf #检查配置
[root@mail named]# vim /var/named/172.16.80.zone
[root@mail named]# chgrp named deo.com.zone 172.16..zone
[root@mail named]# chmod deo.com.zone 172.16..zone
[root@mail named]# named-checkzone "deo.com" deo.com.zone
zone deo.com/IN: loaded serial
OK
[root@mail named]# named-checkzone "80.16.172.in-addr.arpa" 172.16..zone
zone 80.16..in-addr.arpa/IN: loaded serial
OK [root@mail named]# /etc/init.d/named start
[root@mail named]# dig -t MX deo.com @172.16.80.128
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> -t MX deo.com @172.16.80.128
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6781
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; QUESTION SECTION:
;deo.com. IN MX
;; ANSWER SECTION:
deo.com. 600 IN MX 10 mail.deo.com.
;; AUTHORITY SECTION:
deo.com. 600 IN NS ns.deo.com.
;; ADDITIONAL SECTION:
mail.deo.com. 600 IN A 172.16.80.128
ns.deo.com. 600 IN A 172.16.80.128
;; Query time: 0 msec
;; SERVER: 172.16.80.128#53(172.16.80.128)
;; WHEN: Sun Jul 8 22:42:41 2018
;; MSG SIZE rcvd: 95
[root@mail named]# dig -t A mail.deo.com @172.16.80.128
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> -t A mail.deo.com @172.16.80.128
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46422
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;mail.deo.com. IN A
;; ANSWER SECTION:
mail.deo.com. 600 IN A 172.16.80.128
;; AUTHORITY SECTION:
deo.com. 600 IN NS ns.deo.com.
;; ADDITIONAL SECTION:
ns.deo.com. 600 IN A 172.16.80.128
;; Query time: 0 msec
;; SERVER: 172.16.80.128#53(172.16.80.128)
;; WHEN: Sun Jul 8 22:43:14 2018
;; MSG SIZE rcvd: 79
[root@mail named]# dig -x 172.16.80.128 @172.16.80.128
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> -x 172.16.80.128 @172.16.80.128
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36878
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;128.80.16.172.in-addr.arpa. IN PTR
;; ANSWER SECTION:
128.80.16.172.in-addr.arpa. 600 IN PTR mail.deo.com.
128.80.16.172.in-addr.arpa. 600 IN PTR ns.deo.com.
;; AUTHORITY SECTION:
80.16.172.in-addr.arpa. 600 IN NS ns.deo.com.
;; ADDITIONAL SECTION:
ns.deo.com. 600 IN A 172.16.80.128
;; Query time: 0 msec
;; SERVER: 172.16.80.128#53(172.16.80.128)
;; WHEN: Sun Jul 8 22:44:07 2018
;; MSG SIZE rcvd: 117
修改postfix配置文件
[root@mail named]# grep "^[a-z]" /etc/postfix/main.cf
myhostname = mail.deo.com
mydomain = deo.com
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
mynetworks_style = subnet
mynetworks = 172.16.80.0/24,127.0.0.0/8
inet_protocols = ipv4
[root@mail named]# postfix stop
[root@mail named]# postfix start
[root@mail named]# telnet mail.deo.com 25
Trying 172.16.80.128...
Connected to mail.deo.com.
Escape character is '^]'.
220 mail.deo.com ESMTP Postfix
ehlo mail.deo.com
250-mail.deo.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@deo.com
250 2.1.0 Ok
rcpt to:deo@deo.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
hello123
.
250 2.0.0 Ok: queued as 6E6E92615FE
quit
221 2.0.0 Bye
Connection closed by foreign host.
部署dovecto 用来支撑pop3 协议
[root@mail named]# yum install dovecot -y
[root@mail named]# vim /etc/dovecot/dovecot.conf
protocols = imap pop3
postfix+saslauthd 用户认证
[root@mail named]# saslauthd -v #列出支持的认证模块
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
[root@mail named]# vim /etc/sysconfig/saslauthd
#MECH=pam
MECH=shadow
[root@mail named]# /etc/init.d/saslauthd start
[root@mail named]# testsaslauthd -udeo -phello123 #测试该服务是否正常
0: OK "Success."
验证postfix是否支持cyrus风格的sasl认证 # /usr/sbin/postconf -a
cyrus
dovecot
配置postfix vi /etc/postfix/main.cf
mynetworks = 127.0.0.0/8
#mynetworks = 172.16.80.0/28, 127.0.0.0/8
# vi /etc/postfix/main.cf #添加如下内容到最后即可,复制文件时候后面中文去掉,否则有可能乱码有问题
############################CYRUS-SASL############################
broken_sasl_auth_clients = yes ##使用SSL验证客户端身份
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination ###收件人限定
smtpd_sasl_auth_enable = yes ##启用SSL认证
smtpd_sasl_local_domain = $myhostname ##SSL认证的本地域
smtpd_sasl_security_options = noanonymous ##不支持匿名用户
smtpd_sasl_path = smtpd ##指定需使用SSL认证的程序
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
vi /usr/lib64/sasl2/smtpd.conf ##新建文件并添加如下
pwcheck_method: saslauthd ##指定密码检查方法
mech_list: PLAIN LOGIN ##指定认证机制
log_level: 3 #测试时使用,生产中关闭
# postfix reload ##重新加载postfix
[root@mail named]# /etc/init.d/saslauthd restart
测试认证功能
[root@mail ~]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 Welcome to our mail.deo.com ESMTP,Warning: Version not Available!
ehlo mail.deo.com
250-mail.deo.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN ##出现以上两行说明cyrus-sasl认证功能已添加成功
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
发送邮件测试
发送qq邮箱测试
Dovecot 配置 dovecot.conf 文件配置邮件接收的存储位置,要和postfix配置目录一致
/etc/dovecot/conf.d/10-mail.conf 去掉下面一行注释
mail_location = maildir:~/Maildir
[root@mail Maildir]# vim /etc/postfix/main.cf
home_mailbox = Maildir/
至此 邮件收发功能基本完成,下篇介绍虚拟域 虚拟用户
https://www.cnblogs.com/hellojackyleon/p/9286909.html
Postfix+Sasl+Courier-authlib+Dovecot+MySQL+extmail 邮件系统部署的更多相关文章
- 最新ubuntu搭建公网个人邮件服务器(基于postfix,dovecot,mysql)
最近做了一个应用,需要用邮件发通知,但是免费的邮箱每天发信数量是有限制的,所以呢就想着搭建一个自己的邮件服务器,能够实现邮件的发送和接收即可,其中大概花了一个星期找资料,测试,终于成功了,写个教程 ...
- Linux搭建邮件服务器Postfix+Dovecot+MySQL+PHP
用于搭建的服务器信息 阿里云 Centos 6.5 32位 安装过程1.安装Postfix 版本(2:2.6.6-8.el6) yum -y install postfix 安装完成还需要替换系统自带 ...
- Postfix+Dovecot+MySQL搭建邮件服务器
网上有很多使用Postfix搭建邮件服务器的文章,但目前貌似没有看到较为完整的一篇.本例将尝试在Ubuntu系统中使用Postfix+Dovecot+MySQL搭建邮件服务器. 说到邮件服务器,网上有 ...
- mysql数据库主从复制部署笔记
主从复制是mysql中数据库实时同步的一个常用做法了,今天我来给各位介绍一下关于mysql数据库主从复制部署一个过程,希望此例子对各位同学参考参考. 数据库主从复制原理: 数据库的主从复制就是从mas ...
- 多IDC数据分布--MySQL多机房部署 - 学习笔记 - 51CTO技术博客
多IDC数据分布--MySQL多机房部署 - 学习笔记 - 51CTO技术博客 多IDC数据分布--MySQL多机房部署
- Mysql读写分离方案-MySQL Proxy环境部署记录
Mysql的读写分离可以使用MySQL Proxy和Amoeba实现,其实也可以使用MySQL-MMM实现读写分离的自动切换.MySQL Proxy有一项强大功能是实现"读写分离" ...
- shell脚本实例-mysql多机部署
今天我给大家分享shell 安装mysql 多机部署的实例,本次实验是基于各个主机的公钥已经配置好了,如果还不会推送公钥的同学,可以看看我以前写的文章,那里面有写推公钥的实例,mysql 多机部署一般 ...
- CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境, 记坑篇
CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境 CentOS7 + Python3 + D ...
- 基于MySQL+MHA+Haproxy部署高可用负载均衡集群
一.MHA 概述 MHA(Master High Availability)是可以在MySQL上使用的一套高可用方案.所编写的语言为Perl 从名字上我们可以看到.MHA的目的就是为了维护Master ...
随机推荐
- hasOwnProperty自我理解
暂时不考虑ES6中symbol,hasOwnProperty()方法返回的是一个对象上是否包含一个指定属性,如果含有则返回true,如果没有则返回false. 和 in 运算符不同,该方法会忽略掉 ...
- 【版本控制——svn】
reposity_name //版本库 { Passwd //验证密码文件 Authz //权限控制 Server.conf //主配置 } Authz //权限控制 //由[groups]标签控 ...
- asp.net core-项目开发中问题汇总
无法启动进程\Program File\dotnet\dotnet.exe.进程创建失败,出现错误:系统找不到指定的文件如下图: 解放方案:1.修改系统环境变量 2.重启电脑
- laravel查看执行的sql语句
方法一: 我们有时候想测试一段代码生产的 SQL 语句,比如: 我们想看 App\User::all(); 产生的 SQL 语句,我们简单在 routes.php 做个实验即可: //app/Http ...
- 为什么 redis 单线程却能支撑高并发
redis 和 memcached 有什么区别?redis 的线程模型是什么?为什么 redis 单线程却能支撑高并发? 这个是问 redis 的时候,最基本的问题吧,redis 最基本的一个内部原理 ...
- MongoDb第一天
安装之后进入cmd.进入到安装目录下的bin目录下. 任意选一个空目录,建立db,log的文件夹.之后终端命令行里面输入回车. D:\ProgramFiles\MongoDB\Server\3.6\b ...
- idea push reject:push mater to origin/master was rejected by remote
用idea commit之后,执行push操作,总是提示push reject:push mater to origin/master was rejected by remote,如下图 上网说执行 ...
- 0x01.被动信息收集
被动信息收集 基于公开渠道,不与目标系统产生直接交互,尽量避免留下痕迹(不进行大量扫描,正常交互范围) 信息收集内容 IP段 域名 邮件地址(定位邮件服务器,分为个人搭建和公网邮件系统) 文档图片数据 ...
- Docker构建nginx+uwsgi+flask镜像(二)
Dockerfile搭建环境并打包应用 在上一章Docker构建nginx+uwsgi+flask镜像(一)的学习中,我们学会用命令行一句一句在alpine环境中搭建nginx+uwsgi+flask ...
- R语言中的机器学习包
R语言中的机器学习包 Machine Learning & Statistical Learning (机器学习 & 统计学习) 网址:http://cran.r-project ...