postfix+dovecot(不使用mysql)

1.在DNS服务器设置好邮箱服务器的主机记录及MX记录
2.安装postfix
yum -y install postfix
3.修改postfix配置文件
vi /etc/postfix/main.cf  
#myhostname = host.domain.tld  ← 找到此行,将等号后面的部分改写为主机名  
↓  
myhostname = mail.test.com  ← 变为此状态,设置系统的主机名  
#mydomain = domain.tld  ← 找到此行,将等号后面的部分改写为域名  
↓  
mydomain = test.com  ← 变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)  
#myorigin = $mydomain  ← 找到此行,将行首的#去掉  
↓  
myorigin = $mydomain  ← 变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)  
inet_interfaces = localhost  ← 找到此行,将“localhost”改为“all”  
↓  
inet_interfaces = all  ← 变为此状态,接受来自所有网络的请求  
mydestination = $myhostname, localhost.$mydomain, localhost  ← 找到此行,在行为添加“$mydomain”  
↓  
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  ← 变为此状态,指定发给本地邮件的域名  
#relay_domains = $mydestination  ← 找到此行,将行首的#去掉  
↓  
relay_domains = $mydestination  ← 变为此状态,定义允许转发的域名  
#mynetworks = 0.0.0.0  ← 找到此行,依照自己的内网情况修改  
↓  
mynetworks = 0.0.0.0  ← 变为此状态,指定内网和本地的IP地址范围  
#mail_spool_directory = /var/spool/mail  ← 找到这一行,去掉行首的#  
↓  
mail_spool_directory = /var/spool/mail  ← 变为此状态  
#smtpd_banner = $myhostname ESMTP $mail_name  
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  ← 找到这一行,接此行添加如下行:  
smtpd_banner = $myhostname ESMTP unknow  ← 添加这一行,不显示SMTP服务器的相关信息  
在配置文件的文尾,添加如下行:  
smtpd_sasl_auth_enable = yes  ← 服务器使用SMTP认证  
smtpd_sasl_local_domain = $myhostname  ← 指定SMTP认证的本地域名(主机名)  
smtpd_sasl_security_options = noanonymous   ← 不允许匿名的方式认证  
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination  
message_size_limit = 15728640  ← 规定邮件最大尺寸为15MB  
4.配置SMTP认证的相关选项
vi /usr/lib/sasl2/smtpd.conf  ← 编辑SMTP认证的配置文件  
pwcheck_method: saslauthd  
[root@sample ~]# vi /etc/sysconfig/saslauthd  
MECH=shadow  ← 找到这一行,在前面加#  
FLAGS=  ← 找到此行,在等号后面添加“sasldb”  
↓  
FLAGS=sasldb   ← 定义认证方式为sasldb2
5.首先建立用户模板下的邮箱目录,以便于建立新用户时,相应用户的邮箱目录自动被建立。
mkdir /etc/skel/Maildir  ← 在用户模板下建立用户邮箱目录  
chmod 700 /etc/skel/Maildir  ← 设置用户邮箱目录属性为700
然后再为已经存在的用户建立相应邮箱目录。
mkdir /home/yhzhao/Maildir  ← 为用户(这里以centospub用户为例)建立邮箱目录  
chmod 700 /home/yhzhao/Maildir  ← 设置该用户邮箱目录属性为700  
chown yhzhao. /home/yhzhao/Maildir  ← 设置该用户邮箱目录为该用户所有
6.为用户设置SMTP认证密码
view plaincopy to clipboardprint?
saslpasswd2 -u mail.3gf8.com -c yhzhao  ← 为centospub用户设置SMTP认证密码  
Password:  ← 在这里输入密码(不会显示)  
Again (for verification):  ← 再次输入密码
7.改变SALS的属性及归属
chgrp postfix /etc/sasldb2  ← 将数据库归属改为postfix,  
chmod 640 /etc/sasldb2  ← 将数据库属性改为640 
8.将默认的MTA设置为Postfix。
alternatives --config mta  ← 设置默认MTA  
There are 2 programs which provide ‘mta’.  
共有 3 个程序提供“mta”。
选择    命令
-----------------------------------------------
+ 1           /usr/sbin/sendmail.postfix
*  2           /usr/sbin/sendmail.sendmail
3           /usr/sbin/sendmail.exim
按 Enter 来保存当前选择[+],或键入选择号码:  ← 在这里输入1,使Postfix成为默认MTA  
9.启动相应的服务
chkconfig saslauthd on  ← 将SMTP-Auth设置为自启动  
chkconfig --list saslauthd  ← 确认SMTP-Auth服务状态  
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 确认2~5为on的状态就OK  
/etc/rc.d/init.d/saslauthd start  ← 启动SMTP-Auth  
Starting saslauthd:           [ OK ]  
chkconfig postfix on  ← 将Postfix设置为自启动  
chkconfig --list postfix  ← 确认Postfix服务状态  
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 确认2~5为on的状态就OK  
/etc/rc.d/init.d/postfix start  ← 启动Postfix  
Starting postfix:            [ OK ] 
10.配置dovecot
根据dovecot的版本不同有相应的变化default_mail_env在高版本里面变成maim_location,
vi /etc/dovecot.conf
protocols = imap pop3  ← 变为此状态  
#mail_location = mbox:~/mail:INBOX=/var/mail/%u  ←找到这一行 
mail_location = mbox:~/mail:INBOX=/var/mail/%u← 定义用户邮件目录 
最后,启动 Dovecot ,并将其设置为自启动。
chkconfig dovecot on  ← 设置Dovecot为自启动  
chkconfig –list dovecot  
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 确认2~5为on的状态就OK  
/etc/rc.d/init.d/dovecot start  ← 启动Dovecot服务  
Starting Dovecot Imap:        [ OK ]
通过邮件客户端来设置自己的邮件服务器吧。
测试可以正常收发邮件
对邮件组进行权限控制

1.# vi /etc/postfix/main.cf

添加下面几行:

#设置只能test@test.com 给all@test.com 发邮件
smtpd_restriction_classes = local_only
local_only = check_sender_access hash:/etc/postfix/local_sender, reject
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/local_recipient

2.#vi local_sender

加入允许群发到all的邮件列表:

test@test.com   OK
如果允许本域所有用户可以群发到all,则只添加

test.com  OK

即可。

3.# vi local_recipient
  添加群账号:

all@test.com    local_only

4.建立local_recipient和local_sender的hash表

#  postmap hash:/etc/postfix/local_sender

#  postmap hash:/etc/postfix/local_recipient

在/etc/postfix目录下生成2个db文件:

local_recipient.db和local_sender.db

5.重启Postfix

# /etc/init.d/postfix restart

6.测试:只有在local_sender里的用户才能给all@kin.com群发,其他不受影响。

已经测试通过。

webmail配置

安装openwebmail前需安装:

rpm -ivh perl-suidperl-5.8.8-27.el5.i386.rpm  perl-Text-Iconv-1.7-1.el5.rf.i386.rpm

rpm -ivh openwebmail-2.53-1.i386.rpm openwebmail-data-2.53-1.i386.rpm

cd /var/www/cgi-bin/openwebmail/

./openwebmail-tool.pl  --init

vi etc/openwebmail.conf

domainnames                     test.com(默认为auto)

default_language                zh_CN.GB2312(默认为en)

default_iconset                 Cool3D.Chinese.Simplified

vi etc/defaults/openwebmail.conf

smtpserver                      127.0.0.1
        更改为:
        smtpserver                      192.168.30.16 (更改smtp服务器的地址)

mailspooldir                    /var/spool/mail(此先项与main.cf和dovecot中的  mail_location保持一致,否刚openwebmail收不到邮件)
        authpop3_server               localhost
        更改为:
        authpop3_server               192.168.30.16 (更改pop3服务器的地址)

vi etc/defaults/dbm.conf

dbmopen_ext              none
        更改为:
        dbmopen_ext              .db
        dbmopen_haslock        no
        更改为:
        dbmopen_haslock        yes
        smtpserver                192.168.30.16 (添加smtp服务器的地址)
然后再次执行:./openwebmail-tool.pl --init

vi /etc/httpd/conf/httpd.conf

ServerName mail.test.com:80    -----找到此行,去掉注释后改成服务器名称

AddHandler cgi-script .cgi   ----------找到此行,去掉注释

/etc/init.d/httpd restart     --------------重启http

打开浏览器输入:http://mai.test.com/openwebmail/openwebmail.pl

多域名支持设置

vi /etc/postfix/main.cf
virtual_alias_maps=hash:/etc/postfix/virtual
二、定义虚拟域名转换规则
$ vi /etc/postfix/virtual                  //在文件末尾添加上下面两行
test.cn anything
@test.cn @test.com

who@test.nwho@test.com
三、更新虚拟域名规则
$ postmap /etc/postfix/virtual
四、重启postfix
$ service postfix restart

转载于:https://blog.51cto.com/ryan0817/520588

postfix+dovecot相关推荐

  1. [RHEL] RHEL7.0 下 Postfix + Dovecot 实现邮件发送

    RHEL7.0 下 Postfix + Dovecot 实现邮件发送 一.前言 大家都对邮件服务(mail service)很感兴趣嘛.我在自己 博客站 预言了自己会实战一次,访问量一天到十几(毕竟平 ...

  2. centos6.8 搭建postfix/dovecot邮件服务器

    postfix/dovecot邮件服务器 安装配置参考链接  http://www.cnblogs.com/jkklearn/p/7280045.html (domain 为自己域名 xxx.com) ...

  3. linux邮件自动回复,debian上 postfix+dovecot+squirrelmail 实现 自动回复

    作者:lxq007 本文主要介绍了基于dovecot 的邮件自动回复 的配置过程. 我使用的系统及安装的软件包为Debian GNU/Linux 4.0.postfix 2.3.4-3 .squirr ...

  4. centos dovecot mysql_Centos6.4 配置postfix+dovecot+mysql

    使用Linux用户验证和收发邮件 需要组件 postfix dovecot roundcube postfix 用来收发邮件, 作为SMTP服务器, 监听25端口 dovecot 用作为POP3, I ...

  5. 配置postfix+dovecot+mysql+postfixadmin+squirrelmail 邮件系统笔记

    最近想搭建一个完整的mailserver,查了很多资料,一直没有成功,网上大部分资料是在redhat系列的操作系统上的,而且很多都是采用rpm包. 我现在的系统是suse Linux有许多包已经安装, ...

  6. CentOS 搭建Postfix+Dovecot简单邮件系统

    2019独角兽企业重金招聘Python工程师标准>>> 服务器信息 系统:CentOS 6.5 minimal版本 主机:虚拟机 虚拟机IP:192.168.128.128/24 宿 ...

  7. postfix+Dovecot自建邮箱服务器

    文章目录 一.准备工作 二.搭建DNS服务 三.部署postfix 四.部署Dovecot 五.测试电子邮件系统 六.其他一些问题 一.准备工作 部署环境 1. 服务器:VMware虚拟机1c1t+1 ...

  8. postfix+dovecot+SSL 搭建邮件服务器

    一.配置postfix 首先,我们关闭防火墙 systemctl disable iptables 接下来我们安装postfix yum install postfix 然后我们修改下postfix的 ...

  9. linux mysql 邮件_linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件...

    linux 下 搭建邮件邮件服务器(Postfix+Dovecot)(二)-基于mysql的虚拟账户登陆收发邮件 使用虚拟用户收发邮件安装 九.安装Courier authentication lib ...

最新文章

  1. win7能用的matlab,win7环境下使用matlab7.0(R14)方法
  2. 2021牛客寒假算法基础集训营1 J 一群小青蛙呱蹦呱蹦呱
  3. 对角矩阵和类下三角矩阵的频率和质量数据比较
  4. 区块链BaaS云服务(32)同盾科技 IASC平台“特性”
  5. “最严”整改后的海淀黄庄 :学费收取仍有猫腻
  6. Python 分析谁才是「权利的游戏」真正的主角?
  7. 深度学习基础(五)—— rectifier function and softplus
  8. php对接打码平台,易语言接入打码平台的方法
  9. js 加载html文件内容,js读取txt文件内容
  10. ul1581标准_UL 1581电线电缆燃烧试验
  11. Android广告平台
  12. 北斗导航 | 北斗卫星导航系统用户终端通用数据接口
  13. html一排小标题怎么写,工作总结大标题小标题怎么写
  14. 关于想写我与Java的故事,满脑子却都是与JavaCV纠缠不清的那段日子
  15. Arcesium面试体验|S6(在校园实习)
  16. Fabric Block区块结构解析
  17. 后台nodejs存储图片以及前端显示
  18. 队列的顺序、链式表示与实现
  19. Istio:服务发现和Pilot的架构机制
  20. 成为第一没有捷径:AI新势力MindSpore成长秘籍 | 源创者说

热门文章

  1. Hadoop单词统计
  2. 一套提取自 Ant Design 的优质图标
  3. iOS开发 - OC - 苹果为大家提供的后台:CloudKit 的简单使用
  4. springMVC+Mybatis实现查询分页
  5. DAY09 NETWORK Cisco简单不同网络主机通信
  6. Part I 1.介绍Lustre文件系统
  7. 程序员面试金典——2.4链表分割
  8. 【Spark】快速简介
  9. np.squeeze():把张量中维度为1的维度去掉
  10. DevExpress 换肤