深圳福田建设局网站首页,网站推广营销效果,官方网站举例,wordpress图片本地化工具这篇文章原本是2008年发表的#xff0c;近期几天照此笔记又安装了一遍系统。这里更新一下记录。作者#xff1a;wangdy本文发表于 http://blog.csdn.net/aryang/article/details/40593283 转载请注明#xff01;1. 概述 安装环境是CentOS6.5#xff0c;拿到server的时候仅… 这篇文章原本是2008年发表的近期几天照此笔记又安装了一遍系统。这里更新一下记录。 作者wangdy 本文发表于 http://blog.csdn.net/aryang/article/details/40593283 转载请注明 1. 概述 安装环境是CentOS6.5拿到server的时候仅仅有根文件夹的分区。邮件准备存储到 /var/mailbox下后面内容会出现多次假设要改动请注意不要有遗漏的地方。 /var/spool/postfix是postfix存储队列的地方。 /var/vmail是用来存储邮件的。 有条件的建议对 /var/spool/postfix和 /var/vmail进行了单独分区。 CentOS提供了非常方便的yum在线安装。我的基本原则是非重要、对版本号不敏感的模块尽量用yum安装。邮件系统主要模块则用源代码编译安装。 首先用yum安装的模块有mysql mysql-server mysql-devel db4-devel openssl gcc libxml2 libxml2-develgcc-c 几个模块都须要用到PCRE。 先说明一下几个模块的搭配。 MTA用的是postfix-2.5.17。 web模块是最先须要确定的由于它决定了邮箱系统最核心的数据结构这里选用国产的extmail其它全部模块都依照extmail的结构进行配置改动。 webmail使用 extmail-1.0.5web管理模块用extman-0.2.5。 extmail对maildrop的自己主动回复、转发等提供了非常好的支持。所以MDA採用最流行的maildrop2.5.4 这里面简单说一下为什么要用maildrop。 对虚拟用户投递的支持。postfix自带了一个投递代理(MDA)virtual virtual投递代理在 master.cf里描写叙述为 virtual unix - n n - - virtual 假设我们在main.cf里设置virtual_transport virtual。就表示对于包括在 virtual_mailbox_domains域名里的邮件。都使用virtual进行投递。 postfix自带的virtual仅仅提供了最主要的QUOTA功能。假设想使用更复杂的功能如自己主动转发自己主动回复。邮件自己定义过滤等就须要换成更高级的MDA。 当然可选择的MDA有非常多种比方procmail, maildrop等。我这里选用maildrop。 用户信息存储方式也有非常多可选的。比方mysql,ldap等。这里选mysql原因是各个模块包含extmail等对这个支持最好最方便最简单。 maildrop在投递邮件的时候。须要确定一些数据比方收件用户的Maildir的路径保存邮件用的uidgid邮箱容量等。这些数据须要 courier-authlib来提供。 整个系统模块间的作用和关系是 postfix作为MTA(Mail Transfer Agent), 负责创建smtp服务smtpd接收本域用户或其它域名server投递来的邮件。负责向其它server投递转发邮件管理邮件队列 maildrop作为MDA(Mail Delivery Agent)负责把从postfix接收到邮件存入邮件夹同一时候还支持自己主动转发、自己主动回复。邮件过滤等功能 courier-authlib 为 maildrop 提供与用户相关的信息查询 dovecot提供系统的POP3和IMAP服务同一时候给postfix提供SMTP的SASL认证服务。 2. 系统基础配置 假设系统已经安装postfix请先卸载 创建邮箱存储文件夹 /var/mailbox 子文件夹结构为 ./[domain]/[username] 创建负责邮件存取的用户和组帐户 vmail。注意要指定uid和gid。这两个id在后面非常多配置里要用到 #groupadd -g 1001 vmail #useradd -g vmail -u 1001 -s /sbin/nologin #chown vmail:vmail /var/mailbox #chmod 700 /var/mailbox postfix安装的是须要指定几个专门的用户和组 #groupadd -g 2001 postfix #useradd -g postfix -u 1001 -s /sbin/nologin -M postfix #groupadd-g 2002 postdrop #useradd-g postdrop -u 2002 -s /bin/false -M postdrop 3. courier-authlib安装 下载 courier-authlib-0.66.1 ./configure --sysconfdir/etc --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --with-authmysql --with-mysql-libs/usr/local/mysql/lib/mysql --with-mysql-includes/usr/local/mysql/include/mysql --with-redhat --with-authmysqlrc/etc/authmysqlrc --with-authdaemonrc/etc/authdaemonrc --with-mailuser1001 --with-mailgroup1001 注意此处已经用到了vmail用户的uid和gid #cp /etc/authdaemonrc.dist /etc/authdaemonrc 改动配置文件启用mysql用户认证方式 #authmodulelistauthuserdb authmysql authcustom authpipe authmodulelistauthmysql #authmodulelistorigauthuserdb authmysql authcustom authpipe authmodulelistorigauthmysql authmysql的配置文件 #cp /etc/authmysqlrc.dist /etc/authmysqlrc 改动相关配置当中 MYSQL_USER_TABLE mailbox MYSQL_CRYPT_PWFIELD crypt MYSQL_SELECT_CLAUSE SELECT username as id,password as crypt, as clear,\ 1001 as uid,1001 as gid, \ CONCAT(/var/mailbox/,homedir) as home, \ CONCAT(/var/mailbox/,maildir) as maildir, \ quota, \ name \ FROM mailbox \ WHERE active 1 and username $(local_part)$(domain) 事实上就是配置了数据源是什么mysql。怎么连接运行什么sql语句查询用户信息数据的字段名是什么等。 启动auth服务 # /usr/local/libexec/courier-authlib/authdaemond 4. Dovecot安装 下载dovecot-2.0.21.tar.gz #./configure--prefix/usr/local/dovecot --sysconfdir/etc --with-sql --with-mysql #make #make install 须要ssl支持能够加上參数--with-sslopenssl 拷贝 doc/example-config/下的 dovecot.conf 至 /etc/dovecot 配置dovecot.conf base_dir/var/run/dovecot #支持的用户协议 protocolsimap imaps pop3 pop3s listen* disable_plaintext_auth no #是否启用ssl ssl_disable yes #邮件存储位置,%d表示域名%n表示username mail_location maildir:/var/vmail/%d/%n/Maildir pop3_uidl_format%08Xu%08Xv authdefault { ... mechanisms plain login digest-md5 cram-md5 #验证password的配置文件 passdb sql { args /etc/dovecot/dovecot-sql.conf } ... #查询用户信息的配置文件 userdbsql { args /etc/dovecot/dovecot-sql.conf } ... socketlisten { ... client { path /var/spool/postfix/private/auth mode 0660 user postfix group postfix } } } 编辑/etc/dovecot/dovecot-sql.conf driver mysql connect hostlocalhost dbnameextmail userextmail passwordextmail default_pass_schemeMD5-CRYPT password_query SELECT password, maildir as userdb_home FROM mailbox WHERE username %u user_query select 1001 as uid ,1001 as gid from mailbox where username%u And active1 注意文件中的username口令。 password_query是pop3 or imap登录的时候运行的传username查密码邮箱文件夹 user_query是查询用户存取邮件用的uid和gid的这里写死了。。 创建符号链接 #ln -s/usr/local/dovecot/sbin/dovecot /usr/bin/dovecot 启动dovecot服务 # dovecot 假设出错。看看 /var/log/dovecot 5. 安装 maildrop 下载 maildrop-2.5.4.tar.gz ./configure--enable-sendmail/usr/sbin/sendmail --enable-trusted-usersroot vmail--enable-syslog1 --enable-maildirquota --enable-maildrop-uid1001--enable-maildrop-uid1001 --with-trashquota --with-dirsync make make install /etc/postfix/master.cf里添加 maildrop unix - n n - - pipe flagsDRhu uservmailargv/usr/local/bin/maildrop -d ${recipient} 6. 安装 postfix 下载postfix-2.5.17.tar.gz 编译 # make CCARGS-DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE\dovecot\\ -DHAS_PCRE-DHAS_MYSQL \ -I/usr/include/-I/usr/local/include -I/usr/include/mysql/ \ AUXLIBS-L/usr/local/lib-L/usr/lib/mysql -lmysqlclient -lpcre # make # make install -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE\dovecot\ 表示启用SASL身份认证并默认使用dovecot。 mysql的几个路径能够依据实际情况做改动我这里的文件夹都是yum默认安装的。 注意make參数里加上正确的mysql -I 头文件所在文件夹 -L动态库所在文件夹 make install的提问所有回车默认。 install的时候假设默认參数里没有值。请依据错误提示认真检查 导入extmail的mysql表结构和数据。 下载extman-0.2.5.tar.gz 解开后进入 docs文件夹 建库建表 # mysql-u root -p extmail.sql 注意extmail.sql里配置的数据库username口令都是extmail。能够编辑脚本改动。 extmail.sql里创建的数据库用户 webman 是用在web后台管理的extmail用在全部其它地方包含postfix邮件收发dovecot帐户验证、邮件收发webmail里等。 导入初始数据 #mysql-u root -p init.sql 能够先吧 init.sql文件中的extmail.org改成你自己的域名。或登录web管理后再加入域名 把文件夹下 mysql_*.cf所有拷贝至/etc/postfix # cpmysql_*.cf /etc/postfix/ 改动cf文件中的username口令 继续配置 postfix # mv/etc/aliases /etc/aliases.old # ln -s/etc/postfix/aliases /etc/aliases # /usr/bin/newaliases 编辑 /etc/postfix/main.cf #邮件server域名 myhostname mail.abc.com #邮箱域名 mydomain abc.com myorigin localhost mydestination $myhostname localhost localhost.$mydomain #能够信赖的网络后面的permit_mynetworks 说的就是这 mynetworks 127.0.0.0/8 inet_interfaces all home_mailbox mbox smtpd_banner Welcome to ESMTP Server #设置能够随意从本机转发邮件的域名黑莓什么的可能用到 #relay_domains alias_maps sendmail_path /usr/sbin/sendmail newaliases_path /usr/bin/newaliases mailq_path /usr/bin/mailq setgid_group postdrop html_directory no manpage_directory /usr/local/man sample_directory /etc/postfix unknown_local_recipient_reject_code 450 non_fqdn_reject_code 450 unknown_virtual_alias_reject_code 450 unknown_virtual_mailbox_reject_code 450 maps_rbl_reject_code 450 maximal_queue_lifetime 1 bounce_queue_lifetime 0 #VritualMailbox settings #查询域名的配置 virtual_mailbox_domains mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_alias_domains virtual_alias_maps mysql:/etc/postfix/mysql_virtual_alias_maps.cf #用maildrop投递邮件后面会安装 virtual_transport maildropmaildrop_destination_recipient_limit1 #QUOTA #设置邮件限制大小和邮箱最大容量 message_size_limit 500001000 mailbox_size_limit 500001000 virtual_mailbox_limit 209715200 #SASLESMTP Authenticat #注: smtpd说的是接收邮件client发送邮件的服务 smtp说的是给别的邮件server投递用的服务 #这个得加yes不然你就为互联网贡献一个垃圾邮件server smtpd_sasl_auth_enable yes #这里用到了dovecot ^_^ smtpd_sasl_type dovecot smtpd_sasl_path private/auth broken_sasl_auth_clients yes smtpd_sasl_local_domain smtpd_sasl_security_options noanonymous #注意第二行起有空格 #这个说的是邮件client包含本域用户client和别的server投递进来的提交收件人的时候做的检查 # permit_sasl_authenticated 表示 smtp 鉴权通过的permit。其它几种情况全拒 smtpd_recipient_restrictions permit_sasl_authenticated, permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination #check_recipient_access pcre:/etc/postfix/spamd_filter_access #reject_rbl_client sbl.spamhaus.org, #reject_rbl_client cblless.anti-spam.org.cn, #检查发信人 smtpd_sender_restrictions permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_sender_login_mismatch, reject_authenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatch smtpd_helo_required yes smtpd_helo_restrictions permit_sasl_authenticated, permit_mynetworks, reject_invalid_hostname smtpd_sender_login_maps mysql:/etc/postfix/mysql_virtual_sender_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_maps.cf disable_vrfy_command yes smtpd_client_restrictions permit_mynetworks, check_client_access hash:/etc/postfix/access #TLS #smtp的tls支持此处不详述 smtpd_use_tls yes smtpd_tls_security_level may smtpd_tls_key_file /etc/postfix/certs/mail.key smtpd_tls_cert_file /etc/postfix/certs/mail.crt smtpd_tls_loglevel 1 smtpd_tls_session_cache_timeout 3600s smtpd_tls_session_cache_database btree:/var/spool/postfix/smtpd_tls_cache tls_random_source dev:/dev/urandom readme_directory no command_directory /usr/sbin daemon_directory /usr/libexec/postfix queue_directory /var/spool/postfix mail_owner postfix data_directory /var/lib/postfix 启动postfix #postfix 启动后注意观察 /etc/log/maillog 里是否有错误信息 7. 安装extmail和extman extman是邮箱的后台管理web注意webman.cf里的配置 邮箱的根文件夹 SYS_MAILDIR_BASE /var/mailbox SYS_DEFAULT_UID 1001 SYS_DEFAULT_GID 1001 SYS_MYSQL_USER webman SYS_MYSQL_PASS webman extmail里的 webmail.cf SYS_MAILDIR_BASE /var/mailbox 祝您成功 版权声明本文博客原创文章博客未经同意不得转载。