Extmail邮件服务器centos搭建(二)

接上一篇Extmail博文继续 https://www.aolens.cn/?p=1018

3.3 postfix开启基于cyrus-sasl的认证

查看sasl有关的安装包

[[email protected]mail ~]# rpm -qa |grep sasl

cyrus-sasl-md5-2.1.23-15.el6_6.2.x86_64

cyrus-sasl-2.1.23-15.el6_6.2.x86_64

cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64

cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64

cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64

cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64

3.3.1

postfix和sasl结合,编辑postfix配置文件

[[email protected] ~]# vim /etc/postfix/main.cf
 
#添加一下配置
 
broken_sasl_auth_clients = yes 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
 
smtpd_sasl_local_domain = $myhostname
 
smtpd_sasl_security_options = noanonymous
 
smtpd_banner = Welcome to our $myhostname SMTP
 
[[email protected] ~]# service postfix restart
 
关闭 postfix:                                             [确定]
 
启动 postfix:                                             [确定]
 
[[email protected] ~]# telnet 127.0.0.1 25
 
Trying 127.0.0.1...
 
Connected to 127.0.0.1.
 
Escape character is ‘^]‘.
 
220 Welcome to our mail.aolens.cn ESMTP,Warning: Version not Available!
 
ehlo mail.aolens.cn
 
250-mail.aolens.cn
 
250-PIPELINING
 
250-SIZE 10240000
 
250-VRFY
 
250-ETRN
 
250-AUTH CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI
 
250-AUTH=CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI
 
250-ENHANCEDSTATUSCODES
 
250-8BITMIME
 
250 DSN

3.3.2 sasl配置

[[email protected] ~]# service saslauthd restart
 
停止 saslauthd:                                           [确定]
 
正在启动 saslauthd:                                       [确定]
 
[[email protected] ~]# chkconfig --add saslauthd
 
[[email protected] ~]# chkconfig saslauthd on

3.4  安装Courier authentication library

下载地址:http://www.courier-mta.org/download.html#authlib

[[email protected] ~]# tar jxf courier-authlib-0.66.4.tar.bz2 -C /usr/local/src/
 
[[email protected] ~]# cd /usr/local/src/courier-authlib-0.66.4/
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# ./configure  
--prefix=/usr/local/courier-authlib  
--sysconfdir=/etc  
--with-authmysql  
--with-mysql-libs=/usr/lib64/mysql  
--with-mysql-includes=/usr/include/mysql  
--with-RedHat  
--with-authmysqlrc=/etc/authmysqlrc  
--with-authdaemonrc=/etc/authdaemonrc  
--with-mailuser=postfix

报错:

configure: error: The Courier Unicode Library 1.2 appears not to be installed. You may need to install a separate development subpackage, in addition to the main package

下载:courier-unicode

https://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2/download

[[email protected] ~]# tar jxf courier-unicode-1.2.tar.bz2
 
[[email protected] ~]# cd courier-unicode-1.2
 
[[email protected] ~/courier-unicode-1.2]# ./configure
 
[[email protected] ~/courier-unicode-1.2]# make && make install && echo 1

再次编译courier-authlib就好了

3.4.2 配置courier-authlib

[[email protected] /usr/local/src/courier-authlib-0.66.4]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# cp /etc/authdaemonrc.dist /etc/authdaemonrc
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# cp /etc/authmysqlrc.dist /etc/authmysqlrc
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# vim /etc/authdaemonrc
 
#authmodulelist="authuserdb authpwd authshadow authmysql authcustom authpipe”
 
#authmodulelistorig="authuserdb authpwd authshadow authmysql authcustom authpipe"
 
authmodulelist="authmysql"
 
authmodulelistorig="authmysql"
 
MYSQL_SERVER        localhost
 
MYSQL_USERNAME      root
 
MYSQL_PASSWORD      aolens
 
MYSQL_SOCKET      /var/lib/mysql/mysql.sock
 
MYSQL_PORT      3306
 
MYSQL_DATABASE      extmail
 
MYSQL_USER_TABLE    mailbox
 
MYSQL_CRYPT_PWFIELD password
 
DEFAULT_DOMAIN        aolens.cn
 
MYSQL_UID_FIELD     ‘2525‘
 
MYSQL_GID_FIELD     ‘2525‘
 
MYSQL_LOGIN_FIELD   username
 
MYSQL_HOME_FIELD    concat(‘/var/mailbox/‘,homedir)
 
MYSQL_MAILDIR_FIELD   concat(‘/var/mailbox/‘,maildir)
 
 
 
[[email protected] /usr/lib64/sasl2]# mkdir -pv /var/mailbox
 
mkdir: 已创建目录 "/var/mailbox"
 
[[email protected] /usr/lib64/sasl2]# chown -R postfix.postfix /var/mailbox

为courier-authlib创建启动脚本

[[email protected] /usr/local/src/courier-authlib-0.66.4]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# chmod +x /etc/init.d/courier-authlib
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# chkconfig --add courier-authlib
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# chkconfig courier-authlib on
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# echo "/usr/local/courier-authlib/lib/courier-authlib/" >> /etc/ld.so.conf.d/courier-authlib.conf
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# ldconfig
 
[[email protected] /usr/local/src/courier-authlib-0.66.4]# service courier-authlib startStarting Courier authentication services: authdaemond

3.4.3配置smtp以及虚拟用户的相关

创建smtpd.conf

pwcheck_method: authdaemond
 
log_level: 3
 
mech_list: PLAIN LOGIN
 
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket

编辑main.cf

##postfix支持SMTP##
 
broken_sasl_auth_clients = yes
 
smtpd_client_restrictions = permit_sasl_authenticated
 
smtpd_sasl_security_options = noanonymous
 
smtpd_sasl_auth_enable = yes
 
smtpd_sasl_local_domain = $myhostname
 
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
 
##postfix支持虚拟用户##
 
virtual_mailbox_base = /var/mailbox
 
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
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
 
virtual_uid_maps = static:2525
 
virtual_gid_maps = static:2525
 
virtual_transport = virtual

3.5 导入数据库

使用extman源码目录下docs中的extmail.sql和init.sql建立数据库:

下载extmail 和extman

http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz

http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz

[[email protected] ~/extman-1.1/docs]# cp mysql_virtual_* /etc/postfix/

创建数据库

[[email protected] ~/extman-1.1/docs]# mysql -uroot -p < extmail.sql
 
[[email protected] ~/extman-1.1/docs]# mysql -uroot -p < init.sql
 
[[email protected] ~/extman-1.1/docs]# service postfix restart
 
关闭 postfix:                                             [确定]
 
启动 postfix:                                             [确定]

3.6 配置dovecot

[[email protected] ~/extman-1.1/docs]# vim /etc/dovecot/conf.d/10-mail.conf
 
#添加
 
mail_location = maildir:/var/mailbox/%d/%n/Maildir
 
[[email protected] ~/extman-1.1/docs]# vim /etc/postfix/main.cf
 
#添加
 
home_mailbox = Maildir/
 
[[email protected] /etc/dovecot/conf.d]# cp  auth-sql.conf.ext auth-sql.conf
 
[[email protected] /etc/dovecot/conf.d]# vim auth-sql.conf
 
#修改
 
passdb {
 
driver = sql
 
#args = /etc/dovecot/dovecot-sql.conf.ext
 
args = /etc/dovecot/dovecot-sql.conf
 
}
 
userdb {
 
driver = sql
 
#args = /etc/dovecot/dovecot-sql.conf.ext
 
args = /etc/dovecot/dovecot-sql.conf
 
}

创建dovecot-mysql.conf

[[email protected] /etc/dovecot/conf.d]# vim /etc/dovecot/dovecot-mysql.conf
 
driver = mysql
 
connect = host=localhost dbname=extmail user=root password=aolens
 
default_pass_scheme = CRYPT
 
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = ‘%u‘
 
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = ‘%u‘
 
[[email protected] /etc/dovecot]# service dovecot start
 
正在启动 Dovecot Imap:                                    [确定]
 
[[email protected] /etc/dovecot]# chkconfig dovecot on

3.7 安装Extmail

[[email protected] ~]# tar zxf extmail-1.2.tar.gz
 
[[email protected] ~]# cp -a extmail-1.2 /var/www/extsuite/extmail
 
[[email protected] ~]# cd /var/www/extsuite/extmail
 
[[email protected] /var/www/extsuite/extmail]# cp webmail.cf.default webmail.cf

3.7.2 修改主配置文件

SYS_MESSAGE_SIZE_LIMIT = 5242880   #用户可以发送的最大邮件
 
SYS_USER_LANG = zh_CN   #语言选择
 
SYS_MAILDIR_BASE =  /var/mailbox #邮件存放位置
 
SYS_MYSQL_USER = root   #数据库配置
 
SYS_MYSQL_PASS = aolens
 
SYS_MYSQL_DB = extmail
 
SYS_MYSQL_HOST = localhost
 
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
 
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

3.8安装extman

[[email protected] ~]# cp -a extman-1.1 /var/www/extsuite/extman
 
[[email protected] /var/www/extsuite/extman]# cp webman.cf.default webman.cf
 
[[email protected] /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi
 
[[email protected] /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi
 
为extman创建临时目录
 
[[email protected] /var/www/extsuite/extman]# mkdir /tmp/extman &&chown -R postfix.postfix /tmp/extman
 
[[email protected] /var/www/extsuite/extman]# vim webman.cf
 
SYS_CAPTCHA_ON = 0   #修改1为0 验证码功能
 
[[email protected] /var/www/extsuite/extman]# service postfix restart
 
关闭 postfix:                                             [确定]
 
启动 postfix:                                             [确定]
 
[[email protected] /var/www/extsuite/extman]# service dovecot restart
 
停止 Dovecot Imap:                                        [确定]
 
正在启动 Dovecot Imap:                                    [确定]
 
[[email protected] /var/www/extsuite/extman]# service saslauthd restart
 
停止 saslauthd:                                           [确定]
 
正在启动 saslauthd:                                       [确定]

3.9测试虚拟用户

[[email protected] ~]# /usr/local/courier-authlib/sbin/authtest -s login [email protected] extmail
 
Authentication succeeded.
 
Authenticated: [email protected]  (uid 2525, gid 2525)
 
Home Directory: /var/mailbox/extmail.org/postmaster
 
Maildir: /var/mailbox/extmail.org/postmaster/Maildir/
 
Quota: (none)
 
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
 
Cleartext Password: extmail
Options: (none)

[email protected]时init.sql里自带的

4 安装perl依赖环境

extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。

[[email protected] ~]# tar zxf Unix-Syslog-1.0.tar.gz -C /usr/local/src/
 
[[email protected] ~]# cd /usr/local/src/Unix-Syslog-1.0/
 
[[email protected] /usr/local/src/Unix-Syslog-1.0]# perl Makefile.PL
 
[[email protected] /usr/local/src/Unix-Syslog-1.0]# make && make install

4.2 配置apache虚拟主机

[[email protected] ~]# vim /etc/httpd/conf/httpd.conf
 
User postfix
 
Group postfix
 
<VirtualHost *:80>
 
ServerName mail.aolens.com
 
DocumentRoot "/var/www/extsuite/extmail/html/"
 
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
 
Alias /extmail /var/www/extsuite/extmail/html
 
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
 
Alias /extman /var/www/extsuite/extman/html
 
</VirtualHost>
 
[[email protected] ~]# service httpd restart

访问mail.aolens.cn

选择登陆邮箱管理:默认的账号密码是:[email protected]   extmail*123*

添加域,添加用户

使用普通用户登录

报错:

Can‘t chdir to /var/mailbox/aolens.cn/aolens/Maildir/, No such file or directory

[/shell][[email protected] /var/www/extsuite]# vim /var/www/extsuite/extman/webman.cf

SYS_MAILDIR_BASE = /var/mailbox

SYS_MYSQL_USER = root

SYS_MYSQL_PASS = aolens

SYS_MYSQL_DB = extmail

SYS_MYSQL_HOST = localhost

SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock[/shell]

就是因为webman.cf没有设置导致创建用户后没有自动创建用户邮件存放路径。

不启动cmdserver 的话系统页面会出现Connection refused

[[email protected] /var/www/extsuite/extman/daemon]# ./cmdserver -d

loaded ok

现在尝试发送邮件:

[email protected] —> [email protected]  邮件发送成功

[email protected] —> [email protected] 发送不成功

报错:

mail postfix/smtpd[6525]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<localhost.localdomain>

修改main.cf

mydestination = $myhostname

邮件发送成功!

时间: 2024-12-11 16:37:12

Extmail邮件服务器centos搭建(二)的相关文章

Extmail邮件服务器centos搭建(一)

原文地址:https://www.aolens.cn/?p=1018 1,Extmail概述 ExtMail Solution 是一个基于优秀开源软件的电子邮件系统解决方案,核心部件包括了Postfix.Amavisd-new.ClamAV.ExtMail.ExtMan.Courier系列软件.是一个功能相对比较齐全的免费电子邮件系统. 而其中Extmail 是一个以perl语言编写,面向大容量/ISP级应用,免费的高性能Webmail软件,主要包括ExtMail.Extman两个部分的程序套件

linux邮件服务器的搭建和安全

邮件系统的特点:快捷,安全,多样性 实现方式: Windows: 电子邮件服务 03 08  exchange Linux: sendmail  [无身份验证 无加密 无防范垃圾邮件,病毒] POSTFIX [模块化,快] Qmail MAA:邮件访问代理  tcp 110 (pop3)  tcp 109 (pop2)  tcp 143 (imp4) MUA: 邮件用户代理 MDA: 邮件的传递/分检代理 实现系统:redhat5系列 打开一台redhat机器 [[email protected

阿里云CentOS Linux服务器上搭建邮件服务器遇到的问题

参考文章: 阿里云CentOS Linux服务器上用postfix搭建邮件服务器 Linux系统下邮件服务器的搭建(Postfix+Dovecot) 本来想自己搭建邮件服务器,但是看到一篇资料表示阿里云为了禁止垃圾邮件,禁用了25端口. 可以使用阿里云的邮件推送服务. SMTP之PHP调用示例 email.class.php下载

postfix 邮件服务器搭建详解

常见的邮件服务器: Sendmail .Qmail .postfix .Zmaile Exchange  . Notes/Domino Coremail  .U-mail zmailer: 新出的邮件服务器.整合前面的邮件 COREMAIL:最早网易使用的工具 Nores/Domino IBM 必须试用 IBM的硬件设备 U-mail : 收费的软件 postfix: 6版以后是默认安装 红帽中免费开源的邮件服务器 邮件系统角色: MUA(邮件用户代理) MTA (邮件传输代理) MDA (邮件

烂泥:Postfix邮件服务器搭建之准备工作

说实话,Postfix邮件服务器的搭建是一件很麻烦的事情,需要各种软件之间的配置和调试.在写这篇文章之前,我也是搭建测试了不下于10次才算把整个流程给走通,今天刚好有时间把整个搭建过程记录下来. 在正式安装postfix之前,我们先来介绍在搭建之前所需要做的准备工作. 一.域名解析 因为邮件服务器牵涉到域名的问题比较多,所以在此我们先来介绍有关域名解析的相关配置. 我们需要在域名解析控制台添加MX.TXT和相关的A记录,在平时的域名解析过程中,使用最多的是DNSPod以及万网,下面分别一一介绍下

烂泥:Postfix邮件服务器搭建之软件安装与配置

本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb Postfix邮件服务器的搭建需要使用到几个软件,分别是cyrus-sasl.postfix.dovecot.postfixadmin.roundcubemail,只有这几个软件相互配合才能搭建一套完整的邮件服务器. PS:本次实验在centos6.5 64bit上进行. 一.软件功能介绍 cyrus-sasl.postfix.dovecot.postfixadmin.roundcub

CentOS6.4下邮件服务器搭建

CentOS6.4下邮件服务器搭建 linux下邮件服务器的搭建大致分为三个步骤 准备工作(真实的生产环境下需要) 发送服务器安装及配置 (Postfix) 接收服务器安装及配置(dovecot) 一. 准备工作 1. 为邮件服务器添加DNS解析 虽然不加DNS解析也能把邮件发出去,但会被大多数邮件服务器当作垃圾邮件.根据我们的实际经验,需要添加三条DNS解析记录:A记录.MX记录.TXT记录 2. 准备存放邮件的硬盘空间 如果用的是阿里云入门级Linux服务器,有一块20G的数据盘未挂载,需要

[转文]linux搭建最简单的邮件服务器

一.首先应该先了解用户和邮件服务器以及邮箱的使用 现在通常使用Email都很容易,这是因为有第三方服务商搭建邮件服务器,用户只需注册然后使用邮箱的收发功能. 但是Internet的邮件系统是通过几个复杂的部分连接而成的,对于用户而言,我们熟悉的Outlook,Foxmail等都是用来收信和发信的,称之为MUA:Mail User Agent,邮件用户代理.MUA并非直接将邮件发送至收件人手中,而是通过MTA:Mail Transfer Agent,邮件传输代理代为传递,Sendmail和Post

Apache James搭建内网邮件服务器

Apache James搭建内网邮件服务器 极客521 | 极客521 2014-08-21 148 阅读 java 大概之前两个礼拜的日子,讨论会介绍了关于了.net内网邮件服务器的搭建.所以自己也很有必要来尝试一把邮件服务器的搭建,这里选取的是james这个工具. 为什么要使用内网邮件服务器? a.安全这里仅限个人观点.对于任何一个企业来说,必要安全保密是非常重要的. b.不受internet的限制虽然说现在到处都是wifi,但是有一个能够自己来控制和使用的邮件服务器肯定是不错的选择. 什么