当前位置: 首页 > 工具软件 > Cyrus SASL > 使用案例 >

CENTOS7架设邮件服务器(实测1000以上用户)postfix+dovecot+cyrus-sasl+openwebmail

子车鸿运
2023-12-01

一、安装环境:
CentOS Linux release 7.7.1908 (Core),关闭防火墙,有独立的内部DNS服务器。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
二、安装postfix:
yum -y install postfix

postfix配置如下(/etc/postfix/main.cf):

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.xxx.xxx #修改邮件主机
mydomain = xxx.xxx #修改域名
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = m y h o s t n a m e , l o c a l h o s t . myhostname, localhost. myhostname,localhost.mydomain, localhost, $mydomain # $mydomain必须要引用,没有引用会出现已域名为结尾的邮件无法接收。
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8, 10.36.0.0/16
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mail_spool_directory = /var/spool/mail #openwebmail 无法支持 Maildir/
smtpd_banner = $myhostname ESMTP
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
#smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd d a e m o n d i r e c t o r y / daemon_directory/ daemondirectory/process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
message_size_limit = 100000000
mailbox_size_limit = 1000000000

systemctl enable postfix

systemctl start postfix
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
三、安装dovecot

yum -y install dovecot

vi /etc/dovecot/dovecot.conf
protocols = imap pop3
listen = *

vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login

vi /etc/dovecot/conf.d/10-mail.conf
first_valid_uid = 501 # uid 501开始的都能登录。默认是1000导致部分邮件账号无法登录
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u #openwebmail支持Mbox

vi /etc/dovecot/conf.d/10-master.conf
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}

vi /etc/dovecot/conf.d/10-ssl.conf
ssl = no

systemctl start dovecot

systemctl enable dovecot

验证:
[root@adm ~]# telnet localhost 110
Trying ::1…
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
+OK Dovecot ready.
user 账号
+OK
pass 密码
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
四、cyrus-sasl配置

yum install cyrus-sasl-*

[root@adm ~]# vi /etc/sysconfig/saslauthd
MECH=shadow

vi /etc/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
log_level: 3

验证:
[root@adm ~]# testsaslauthd -u 账号 -p ‘密码
0: OK “Success.”
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
五、openwebmail
第一步:
到http://www.openwebmail.org/openwebmail/download/处下载如下文件包:
openwebmail-2.53.tar.gz
1 CGI.pm-3.05.tar.gz
2 Text-Iconv-1.2.tar.gz
3 Digest-1.08.tar.gz
4 libiconv-1.9.1.tar.gz (非必须)
5 libnet-1.19.tar.gz
6 Digest-MD5-2.33.tar.gz
7 MIME-Base64-3.01.tar.gz

第二步:
分别对于他们进行编译安装:

[root@linux CGI.pm-3.05]# perl Makefile.PL
Checking if your kit is complete…
Looks good
Writing Makefile for CGI

[root@linux CGI.pm-3.05]# make; make install
Writing /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/CGI/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod

[root@linux openwebmail]# tar zvxf libnet-1.19.tar.gz
[root@linux openwebmail]# cd libnet-1.19
[root@linux libnet-1.19]# perl Makefile.PL
Checking for Socket…ok
Checking for IO::Socket…ok
Checking if your kit is complete…
Looks good
Ah, I see you already have installed libnet before.
Do you want to modify/update your configuration (y|n) ? [no] no
这里提示要不要对原有网络配置进行更新修改,我们选择no
This script will prompt you to enter hostnames that can be used as
defaults for some of the modules in the libnet distribution.
To ensure that you do not enter an invalid hostname, I can perform a
lookup on each hostname you enter. If your internet connection is via
a dialup line then you may not want me to perform these lookups, as
it will require you to be on-line.
Do you want me to perform hostname lookups (y|n) ? [yes]
The following questions all require a list of host names, separated
with spaces. If you do not have a host available for any of the
services, then enter a single space, followed by . To accept the
default, hit
Enter a list of available NNTP hosts : []
Enter a list of available SMTP hosts : []
Enter a list of available POP3 hosts : []
Enter a list of available SNPP hosts : []
Enter a list of available PH Hosts : []
Enter a list of available TIME Hosts : []
Enter a list of available DAYTIME Hosts : []
Do you have a firewall/ftp proxy between your machine and the internet
If you use a SOCKS firewall answer no
(y|n) ? [no]
Normally when FTP needs a data connection the client tells the server
a port to connect to, and the server initiates a connection to the client.
Some setups, in particular firewall setups, can/do not work using this
protocol. In these situations the client must make the connection to the
server, this is called a passive transfer.
Should all FTP connections be passive (y|n) ? [yes]
What is your local internet domain name : []
If you specified some default hosts above, it is possible for me to
do some basic tests when you run make test' This will causemake test’ to be quite a bit slower and, if your
internet connection is via dialup, will require you to be on-line
unless the hosts are local.
Do you want me to run these tests (y|n) ? [yes]
To allow Net::FTP to be tested I will need a hostname. This host
should allow anonymous access and have a /pub directory
What host can I use : []
Writing libnet.cfg
Writing Makefile for Net
make install:同样提示(目前看来是perl编译器有些问题,但不知道会不会对他有影响)
Writing /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/Net/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod
同上安装Digest-MD5-2.33正常
同上安装MIME-Base64-3.01正常
同上安装Text-Iconv-1.2正常
同上安装Digest-1.08正常

第三步:Install a Repostory File for CentOS 7
cd /etc/yum.repo.d
wget ftp://openwebmail.org/pub/openwebmail/el7/openwebmail-el7.repo
yum install openwebmail
yum install gcc perl-CGI
/usr/local/bin/openwebmail-tool --init

The version of Perl on your system (5.016003) does not support set user id.
Attempting to wrap the openwebmail perl files in a C wrapper to enable set
user id capability…
Found C compiler /usr/bin/cc
wrapping file: openwebmail-abook.pl…done
wrapping file: openwebmail-advsearch.pl…done
wrapping file: openwebmail-cal.pl…done
wrapping file: openwebmail-folder.pl…done
wrapping file: openwebmail-main.pl…done
wrapping file: openwebmail-prefs.pl…done
wrapping file: openwebmail-read.pl…done
wrapping file: openwebmail-saprefs.pl…done
wrapping file: openwebmail-send.pl…done
wrapping file: openwebmail-spell.pl…done
wrapping file: openwebmail-tool.pl…done
wrapping file: openwebmail-vdomain.pl…done
wrapping file: openwebmail-viewatt.pl…done
wrapping file: openwebmail-webdisk.pl…done
wrapping file: openwebmail.pl…done

creating db /var/www/cgi-bin/openwebmail/etc/maps/b2g …done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b …done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar …done.

Creating UTF-8 locales…
langconv ar_AE.CP1256 -> ar_AE.UTF-8
langconv ar_AE.ISO8859-6 -> ar_AE.UTF-8
langconv bg_BG.CP1251 -> bg_BG.UTF-8
langconv ca_ES.ISO8859-1 -> ca_ES.UTF-8
langconv cs_CZ.ISO8859-2 -> cs_CZ.UTF-8
langconv da_DK.ISO8859-1 -> da_DK.UTF-8
langconv de_DE.ISO8859-1 -> de_DE.UTF-8
langconv el_GR.ISO8859-7 -> el_GR.UTF-8
langconv en_US.ISO8859-1 -> en_US.UTF-8
langconv es_AR.ISO8859-1 -> es_AR.UTF-8
langconv fi_FI.ISO8859-1 -> fi_FI.UTF-8
langconv fr_FR.ISO8859-1 -> fr_FR.UTF-8
langconv he_IL.CP1255 -> he_IL.UTF-8
langconv hr_HR.ISO8859-2 -> hr_HR.UTF-8
langconv hu_HU.ISO8859-2 -> hu_HU.UTF-8
langconv id_ID.ISO8859-1 -> id_ID.UTF-8
langconv it_IT.ISO8859-1 -> it_IT.UTF-8
langconv ko_KR.eucKR -> ko_KR.UTF-8
langconv lt_LT.CP1257 -> lt_LT.UTF-8
langconv nl_NL.ISO8859-1 -> nl_NL.UTF-8
langconv no_NO.ISO8859-1 -> no_NO.UTF-8
langconv pl_PL.ISO8859-2 -> pl_PL.UTF-8
langconv pt_BR.ISO8859-1 -> pt_BR.UTF-8
langconv pt_PT.ISO8859-1 -> pt_PT.UTF-8
langconv ro_RO.ISO8859-2 -> ro_RO.UTF-8
langconv ru_RU.KOI8-R -> ru_RU.UTF-8
langconv sk_SK.ISO8859-2 -> sk_SK.UTF-8
langconv sl_SI.CP1250 -> sl_SI.UTF-8
langconv sr_CS.ISO8859-2 -> sr_CS.UTF-8
langconv sv_SE.ISO8859-1 -> sv_SE.UTF-8
langconv th_TH.TIS-620 -> th_TH.UTF-8
langconv tr_TR.ISO8859-9 -> tr_TR.UTF-8
langconv uk_UA.KOI8-U -> uk_UA.UTF-8
…done.

Welcome to the OpenWebMail!
This program is going to send a short message back to the developer,
so we could have the idea that who is installing and how many sites are
using this software, the content to be sent is:
OS: Linux 3.10.0-123.el7.x86_64 x86_64
Perl: 5.016003
WebMail: OpenWebMail 2.54 20141206

总结:安装过程中会出现各种各样的异常,参考了很多分享出来的过程,环境不尽相同问题得不到解决,复制命令的时候回出现字符格式不同导致命令出错,分享出来与各位共勉。感谢分享,重要参考链接如下,再次表示感谢。

参考链接:
postfix+dovecot+cyrus-sasl:
https://blog.csdn.net/zuo187qiang/article/details/78201118
openwebmail:
https://blog.csdn.net/weixin_34109408/article/details/93563074 (openwebmail 无法支持 Maildir/,postfix和dovecot格式统一修改)
http://www.openwebmail.org/openwebmail/download/centos/el7/
https://www.cnblogs.com/wwufengg/articles/centos-openwebmail-postfix-perl.html

 类似资料: