教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

[精]搭建postfix+dovecot+ courier-authlib+sasl2+mysql邮件系统(9)

来源:网络收集 时间:2026-08-07
导读: F. 转发域映射 mysql_relay_domains_maps.cf 如果您使用您的邮件系统仅仅为了主机对一些虚拟域备份MX,那么您需要这个映射来告知Postfix为这些域转发信件。 user = postfix password = postfixpassword hosts = 127

F. 转发域映射 mysql_relay_domains_maps.cf

如果您使用您的邮件系统仅仅为了主机对一些虚拟域备份MX,那么您需要这个映射来告知Postfix为这些域转发信件。 user = postfix

password = postfixpassword hosts = 127.0.0.1 dbname = postfix table = domain

select_field = domain where_field = domain

#additional_conditions = and backupmx = '1'

22

(精)搭建postfix+dovecot+ courier-authlib+sasl2+mysql邮件系统

创建虚拟邮件用户 [如需要]

#groupadd -g 5000 vmail$ sudo useradd -m -g vmail -u 5000 -d /home/vmail

-s /bin/bash vmail

在main中的用户id是89, 表示使用系统的postfix作为邮件系统的用户,否则的话我们可以使用上面的方式来创建虚拟邮件的本地映射。

修改前期Postfix的值

main.cf文件控制了Postfix数百个配置参数。这些参数都被配成了默认初始值。我们需要配置下列参数。

$ sudo editor /etc/postfix/main.cf

#The host name where your MX for virtual domains will point to myhostname = mail.domain.com

mydestination = #Remains blank since we are going to host virtual domains

relayhost = #Remains blank unless you are going to use your ISP's SMTP server mail

sending out mails. In which case it would be set to the host name of the ISP's SMTP server

下列参数保持初始默认值。

alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mynetworks = all

mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all

注意:标识为#的地方,需要将其注释掉,因为它不能和虚拟的设置一起存在. warning: do not list domain in BOTH mydestination and virtual_mailbox_domains postfix提示:warning: do not list domain in BOTH mydestination and virtual_mailbox_domains 根据提示,是说我的mydestination选项和mysql里面的virtual_mailbox_domain出现冲突,2者留其一。 分析原因:是系统域名与虚拟帐户的域名冲突了,而mydestination会自动根据机器名生成,因此如果不希望使用它的话,应将其设为空: postconf -e mydestination= 或者手动编辑一下main.cf,加入mydestination= ==============================================================================

7. 配置devecot的虚拟域 (1) 修改主配置文件 dovecot.conf.

base_dir = /var/run/dovecot protocols = imap imaps pop3 pop3s listen = *

disable_plaintext_auth = no shutdown_clients = yes log_path = /var/log/dovecot.log ssl = no

mail_location = maildir:/var/spool/mail/%d/%n #必须是postfix.conf中virtual_mailbox_base

变量/%d/%n 这样才能将信箱的位置指定正确,这样也才能收到信

auth default {

mechanisms = plain login cram-md5 passdb sql {

args = /etc/dovecot-mysql.conf }

userdb sql {

23

(精)搭建postfix+dovecot+ courier-authlib+sasl2+mysql邮件系统

args = /usr/local/etc/dovecot-mysql.conf }

socket listen { client {

path = /var/spool/postfix/private/auth

mode = 0660

user = postfix group = postfix } } }

first_valid_uid =80

dovecot的mysql配置文件

# vim dovecot-mysql.conf driver = mysql

# host 后的sock文件需要先用locate mysql.sock 查找到其确切的位置

connect = host=/var/lib/mysql/mysql.sock dbname=postfix user=postfix password=postfix

default_pass_scheme = MD5 #必须指定,因为我们保存用户时就是用md5加密了的

password_query = SELECT password FROM mailbox WHERE username = '%u' user_query = SELECT maildir, 201 AS uid, 202 AS gid FROM mailbox

WHERE username = '%u' =============找不到 mysql.sock 的处理方法! Got an error: Connection error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' mysql.sock 突然消失算是常见的问题,如果是第一次安装MySQL后运行时出现,那只要找出 mysql.sock 在哪里就可以了。 以上的信息表明,mysql.sock应该是在 /var/lib/mysql/ 下 ,如果你找了没找到就: #locate mysql.sock 就会出来了,接着你就可以 #mysqladmin -S /路径/mysql.sock -u root Dec 13 01:26:50 mail dovecot: pop3(mm2@yt.com): Error: user mm2@yt.com: Initialization failed: Initializing mail storage from mail_location setting failed: Ambiguous mail location setting, don't know what to do with it: Maildir/ (try prefixing it with mbox: or maildir:) 主要原因是,在使用基于mysql的虚拟用户时,dovecot的dovecot.cf中的mail_location配置错误,应该将其配置成一个具体的可到达的值,通常是以如下形式表示 : virtual_mailbox_base = /var/spool/mail 即mail_location = maildir:/var/spool/mail/%d/%n/Maildir 后面的Maildir表示虚拟用户自己的目录 。

接下来我们可以使用telnet命令来重新进行测试.

至此,我们已经让我们的postfix和 dovecot支持mysql管理的虚拟域了,但这还存在一个问题:就是用户在用smtp发信时并没有进行认证,所以邮件主机完全可能被当作垃圾中转战,这显然不是我们需要的。接下来我们就可以通过安装认证机制来解决这个问题。

7.安装验证库courier-authlib , 需要从相关风站下载安装

# tar -jxvf courier-authlib-0.63.1.20110619.tar.bz2 (建议安装courier-authlib-0.63.0.tar.bz2)

24

(精)搭建postfix+dovecot+ courier-authlib+sasl2+mysql邮件系统

最新版为courier-authlib-0.63.1.20110619.tar.bz2 下载地址为: http://www.courier-mta.org/download.php#authlib

注意:这是最新的软件包,可能存在bug,我在编译过程中没有通过(错误现象在下面有描述),最后尝试改为courier-authlib-0.63.0.tar.bz2后,成功make,建议直接安装courier-authlib-0.63.0.tar.bz2 # cd courier-authlib-0.63.0 # ./configure \\

--prefix=/usr/local/courier-authlib \\ --without-stdheaderdir \\ --without-authuserdb \\ --without-authpam \\ --without-authldap \\ --without-authpwd \\ --without-authshadow \\ --without-authvchkpw \\ --without-authpgsql \\ --without-authcustom \\ --with-authmysql \\

--with-mysql-libs=/usr/local/mysql/lib \\ 此处路径根据自己的配置环境而定!! --with-mysql-includes=/usr/local/mysql/include \\ 此处路径根据自己的配置环境而定!! --with-redhat \\

…… 此处隐藏:3657字,全部文档内容请下载后查看。喜欢就下载吧 ……

[精]搭建postfix+dovecot+ courier-authlib+sasl2+mysql邮件系统(9).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/519945.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)