热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Postfix+Dovecot邮局服务配置过程指南

配置环境CentOS5.5,查询CentOS版本命令如下:[root@localhost~]#lsb_release-aLSBVersion::core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarchDistributorID:CentOSD

配置环境CentOS5.5,查询CentOS版本命令如下:

[root@localhost ~]# lsb_release -a
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description:    CentOS release 5.5 (Final)
Release:        5.5
Codename:       Final

 

关闭sendmail

[root@localhost ~]# /etc/init.d/sendmail stop

关闭sendmail自启动:

[root@localhost ~]# chkconfig sendmail off

1. 在CentOS5.5中使用yum install postfix会安装postfix-2.3.3-2.3.el5_6,当我们配置使用dovecot认证的时候会出现错误fatal: no SASL authentication mechanisms

2. 在CentOS5.5中使用yum install dovecot会安装dovecot-1.0.7-7.el5,会出现private/auth没有权限问题

正确方法,下载dovecot-1.2.17.tar.gz      postfix-2.7.3.tar.gz

 

创建用户

useradd -s /sbin/nologin -d /dev/null dovecot

tar -zxvf dovecot-1.2.17.tar.gz     

cd dovecot-1.2.17

./configure && make && make install

cp /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf

配置dovecot

vi /usr/local/etc/dovecot.conf
base_dir = /var/run/dovecot/
protocols = imap   pop3 (修改)
listen = *
ssl_disable = yes
login_dir = /var/run/dovecot/login
login_user = dovecot
default_mail_env = maildir:/var/mail/vhosts/%d/%n/   (修改)
disable_plaintext_auth = no
pop3_uidl_format = %v
passdb passwd-file {
     # Path for passwd-file
     args = /etc/postfix/passwd
   }
userdb passwd-file {
     # Path for passwd-file
     args = /etc/postfix/passwd
   }

     auth default {   (默认打开)
       mechanisms = plain login (修改)
  
       socket listen {
         client {
           path = /var/spool/postfix/private/auth
           mode = 0660
           user = postfix
           group = postfix
         }
       }
}

 

 

安装POSTFIX
建立用户
groupadd -g 12345 postfix
useradd -u 12345 -g postfix -s /sbin/nologin -d /dev/null postfix
groupadd -g 54321 postdrop
groupadd -g 5000 vmail
useradd -u 5000 -g vmail -s /sbin/nologin -d /dev/null vmail
安装
tar -zxvf postfix-2.7.3.tar.gz
cd postfix-2.7.3

make makefiles CCARGS='-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\"dovecot\"'
make
make install
(一路回车)
3, 修改main.cf
vi /etc/postfix/main.cf:
##添加如下代码
#smtp auth   (SMTP 认证)
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_optiOns= noanonymous
smtpd_recipient_restrictiOns= permit_sasl_authenticated permit_auth_destination reject
#virtual mailbox domain
virtual_mailbox_domains=/etc/postfix/vdomains
virtual_mailbox_base=/var/mail/vhosts
virtual_mailbox_maps=hash:/etc/postfix/vmailbox
virtual_mailbox_uid=100
virtual_uid_maps=static:5000
virtual_gid_maps=static:5000
virtual_alias_maps=hash:/etc/postfix/virtual
添加域名,添加用户
例如要添加的域名:test.com,添加的用户:test@test.com 密码test
1,添家域名
vi /etc/postfix/vdomains
test.com
2,添加用户
vi /etc/postfix/vmailbox
test@test.com test.com/test/
mkdir /var/mail/vhosts
chown vmail.vmail /var/mail/vhosts
postmap /etc/postfix/vdomains
postmap /etc/postfix/vmailbox
postmap /etc/postfix/virtual
3,建立密码文件
vi /etc/postfix/passwd
test@test.com:{plain}test:5000:5000::/var/mail/vhosts/test.com/test/
用户名:{plain}密码:(邮件存储目录的用户和组):: 邮件存储目录
以后在添加用户的时候
添加存在域的用户
test2@test.com   密码:test2
1,修改 vmailbox
/etc/postfix/vmailbox
test2@test.com test.com/test2/
#postmap /etc/postfix/vmailbox
2,修改passwd
/etc/postfix/passwd
test2@test.com:{plain} test2:5000:5000::/var/mail/vhosts/test.com/test2/

添加不存在域的用户,先建立域名
test@abc.com 密码:test2006
1,修改vdomains 添加 abc.com
vi /etc/postfix/vdomains
abc.com
2,修改 vmailbox
test@abc.com abc.com/test/
#postmap /etc/postfix/vmailbox
3,修改 pssswd
test@abc.com:{plain}test2006:5000:5000::/var/mail/vhosts/ abc.com/test/
centos系统安装POSTFIX时需要重新注册下
修改/etc/postfix/main.cf
aliases map   的位置   指向/etc/postfix/aliases
aliases db   的位置   指向/etc/postfix/aliases
执行
newaliases
七,   启动
#dovecot
#postfix start
八, 测试
#netstat ?nlp
查看 110,25 ,143   端口是否开放
通过以下命令获得test@test.com的用户名及密码的BASE64编码:
perl -e 'use MIME::Base64; print encode_base64("test@test.com")'
dGVzdC5jb20=
perl -e 'use MIME::Base64; print encode_base64("test")'
dGVzdA==
然后本机测试,其过程如下(蓝色的文字是我们输入/发送到Postfix的)
[root@smtp root]# telnet localhost 25
Trying 127.0.0.1...
Connected to smtp.test.com (127.0.0.1).
Escape character is '^]'.
220 smtp.trade.abc.cn ESMTP Postfix
ehlo aa.com
250-smtp.test.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
dGVzdC5jb20=
334 UGFzc3dvcmQ6
dGVzdA==
235 2.0.0 Authentication successful
mail from:>
250 2.1.0 Ok
rcpt to:>
250 2.1.5 Ok
data
354 End data with .
good mail
.
250 2.0.0 Ok: queued as 1F2706FDDA
出现235 Authentication Successful 表明认证成功了。
这样 就以test@163.com发送一封邮件给刚建立的用户 test@test.com

如果上面方式行不通:使用如下测试

[root@localhost sasl2]# perl -MMIME::Base64 -e \
>     'print encode_base64("test\@test.com\0test\@test.com\0test")';
dGVzdEB0ZXN0LmNvbQB0ZXN0QHRlc3QuY29tAHRlc3Q=
[root@localhost sasl2]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 smtp.test.com ESMTP Postfix
auth plain dGVzdEB0ZXN0LmNvbQB0ZXN0QHRlc3QuY29tAHRlc3Q=
235 2.7.0 Authentication successful

 

postfix warning: dict_nis_init: NIS domain name not set - NIS lookups disabled 解决方法
[root@mail postfix]# postalias /etc/postfix/aliases 
在/etc/postfix/main.cf中加入下面配置信息
alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases

测试 110

[root@smtp root]# telnet localhost 110
Trying 127.0.0.1...
Connected to smtp.test.com (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
user

test@test.com
+OK
pass test
+OK Logged in.
list
+OK 1 messages:
retr 1
dele 1
1 481

 

 


推荐阅读
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 本文介绍了Perl的测试框架Test::Base,它是一个数据驱动的测试框架,可以自动进行单元测试,省去手工编写测试程序的麻烦。与Test::More完全兼容,使用方法简单。以plural函数为例,展示了Test::Base的使用方法。 ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • Ubuntu 9.04中安装谷歌Chromium浏览器及使用体验[图文]
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 欢乐的票圈重构之旅——RecyclerView的头尾布局增加
    项目重构的Git地址:https:github.comrazerdpFriendCircletreemain-dev项目同步更新的文集:http:www.jianshu.comno ... [详细]
  • 本文介绍了一个从入门到高手的VB.NET源代码,通过学习这些源代码,可以在21天内成为VB.NET高手。文章提供了下载地址,并提醒读者加入作者的QQ群和收藏作者的博客。 ... [详细]
  • CentOS7.8下编译muduo库找不到Boost库报错的解决方法
    本文介绍了在CentOS7.8下编译muduo库时出现找不到Boost库报错的问题,并提供了解决方法。文章详细介绍了从Github上下载muduo和muduo-tutorial源代码的步骤,并指导如何编译muduo库。最后,作者提供了陈硕老师的Github链接和muduo库的简介。 ... [详细]
  • PHP组合工具以及开发所需的工具
    本文介绍了PHP开发中常用的组合工具和开发所需的工具。对于数据分析软件,包括Excel、hihidata、SPSS、SAS、MARLAB、Eview以及各种BI与报表工具等。同时还介绍了PHP开发所需的PHP MySQL Apache集成环境,包括推荐的AppServ等版本。 ... [详细]
  • 本文介绍了某点评网的搜索策略,包括名称和地址的匹配策略,模糊匹配的方法以及不同口音和拼音的近似发音。同时提供了一些例子来说明这些策略的应用。 ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • Opencv提供了几种分类器,例程里通过字符识别来进行说明的1、支持向量机(SVM):给定训练样本,支持向量机建立一个超平面作为决策平面,使得正例和反例之间的隔离边缘被最大化。函数原型:训练原型cv ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 如题如示,在网上查了下c#直接操作ppt的例子,但都只是很简单的写了下打开PPT插入标题插入一个图表等,但是都没有更具体的有如何可以直接更改PPT图表的数据源数据的例子。我现在的需求是,我有一个P ... [详细]
author-avatar
HVV_Ha8m
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有