如何在CentOS 8/RHEL 8上配置Linux邮件服务器Qmail
时间:2020-03-21 11:42:59 来源:igfitidea点击:
Qmail成立于2003年6月。
汇集在一起为任何需要安装和配置帮助的人提供免费和开放的资源。
它是一种适用于几乎所有环境的令人难以置信的快速,稳定和安全的邮件解决方案。
由于世界各地忠实的qmail粉丝的慷慨贡献,Qmailrocks继续增长和改进。
步骤1(下载软件并解压缩qmail pkgs)
# wget http://www.qmailrocks.org/downloads/qmailrocks.tar.gz # mkdir /downloads # cd /downloads # tar zxvf qmailrocks.tar.gz
步骤2(自行安装Qmail)
# /downloads/qmailrocks/scripts/install/qmr_install_linux-s1.script # /downloads/qmailrocks/scripts/util/qmail_big_patches.script
现在我们建立Qmail ...
# cd /usr/src/qmail/qmail-1.03 # make man && make setup check # ./config-fast your_fqdn_hostname (ex: ./config-fast mail.galaxy.com)
# make cert
Country Name (2 letter code) [GB]:IN State or Province Name (full name) [Berkshire]: MH Locality Name (eg, city) [Newbury]: Netherlands Organization Name (eg, company) [My Company Ltd]: MCH Organizational Unit Name (eg, section) []: Computer Cell Common Name (eg, your name or your server's hostname) []:mail.theitroad.com Email Address []:[email protected]
步骤3(EZmlm)
# cd /downloads/qmailrocks/ # tar zxvf ezmlm-0.53-idx-0.41.tar.gz # cd ezmlm-0.53-idx-0.41 # make && make setup
步骤4(自动回覆)
# cd /downloads/qmailrocks # tar zxvf autorespond-2.0.5.tar.gz # cd autorespond-2.0.5 # make && make install
步骤5(Vpopmail)
# cd /downloads/qmailrocks # tar zxvf vpopmail-5.4.5.tar.gz # cd vpopmail-5.4.5 # ./configure --enable-logging=p # make && make install-strip
步骤6(Vqadmin)
# cd /downloads/qmailrocks # tar zxvf vqadmin-2.3.6.tar.gz # cd vqadmin-2.3.6 # ./configure --enable-cgibindir=/var/www/cgi-bin --enablehtmldir=/var/www/html/ # make && make install-strip
现在,我们需要将以下内容添加到服务器的Apache配置文件(通常为httpd.conf)中
<Directory "/var/www/cgi-bin/vqadmin"> deny from all Options ExecCGI AllowOverride AuthConfig Order deny,allow </Directory>
此外,在Apache主配置文件中,我们需要将“ AllowOveride”选项设置为“ All”。
例如:AllowOveride All
# cd /var/www/cgi-bin/vqadmin # vi .htaccess AuthType Basic AuthUserFile /usr/local/apache/conf/vqadmin.passwd AuthName vQadmin require valid-user satisfy any # chown apache .htaccess # htpasswd -bc /usr/local/apache/conf/vqadmin.passwd admin admin # chmod 644 /usr/local/apache/conf/vqadmin.passwd # apachectl stop # apachectl start # http://mail.galaxy.com/cgi-bin/vqadmin/vqadmin.cgi
步骤7(邮件投递)
# cd /downloads/qmailrocks # tar zxvf maildrop-1.6.3.tar.gz # cd maildrop-1.6.3 # ./configure --prefix=/usr/local --exec-prefix=/usr/local --enablemaildrop-uid=root --enable-maildrop-gid=vchkpw --enablemaildirquota # make && make install-strip && make install-man
步骤8(Qmailadmin)
# cd /downloads/qmailrocks # tar zxvf qmailadmin-1.2.1.tar.gz # cd qmailadmin-1.2.1 # ./configure --enable-cgibindir=/var/www/cgi-bin --enablehtmldir=/var/www/html/ # make && make install-strip
步骤9(确定Qmail)
# /downloads/qmailrocks/scripts/finalize/linux/finalize_linux.script
找到“ mail.example.com”并将其更改为服务器的主机名。
例如:mail.galaxy.com。
# vi /var/qmail/supervise/qmail-pop3d/run # vi /var/qmail/supervise/qmail-smtpd/run
接下来,我们将终止所有正在运行的qmail进程,以便我们实现一些最终配置。
# qmailctl stop
设置选择性中继Localhost
# echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp # qmailctl cdb # echo [email protected] > /var/qmail/alias/.qmail-root # echo [email protected]> /var/qmail/alias/.qmail-postmaster # echo [email protected]> /var/qmail/alias/.qmail-mailerdaemon # ln -s /var/qmail/alias/.qmail-root /var/qmail/alias/.qmailanonymous # chmod 644 /var/qmail/alias/.qmail*
删除Sendmail
# service sendmail restart # rpm -qa | grep sendmail # rpm -e --nodeps sendmail-x.x.x.x # rpm -e --nodeps sendmail-doc-x.x.x.x # rpm -e --nodeps sendmail-devel-x.x.x.x # rpm -e --nodeps sendmail-cf-x.x.x.x # /etc/rc.d/init.d/sendmail stop (to stop Sendmail) # mv /usr/lib/sendmail /usr/lib/sendmail.old # mv /usr/sbin/sendmail /usr/sbin/sendmail.old # chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old
卸载postfix
# rpm -qa | grep postfix # postfix-x.x-x # /etc/rc.d/init.d/postfix stop # rpm -e nodeps postfix-x.x-x # ln -s /var/qmail/bin/sendmail /usr/lib/sendmail # ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
步骤10(启动qmail)
# /downloads/qmailrocks/scripts/util/qmr_inst_check # qmailctl stop # qmailctl start # qmailctl stat # telnet localhost 110 Trying 192.168.1.10... Connected to 192.168.1.10. Escape character is '^]'. +OK <[email protected]> user [email protected] (enter your username here remember to use the full e-mail address) +OK pass galaxy +OK quit +OK Connection closed by foreign host.
步骤11(通过Courierpassd安装Courier-imap/imaps)
# cd /downloads/qmailrocks # tar jxvf courier-authlib-0.55.tar.bz2 # cd courier-authlib-0.55 # ./configure --prefix=/usr/local --exec-prefix=/usr/local --withauthvchkpw--without-authldap --without-authmysql --disable-rootcheck--with-ssl --with-authchangepwdir=/usr/local/libexec/authlib --with-redhat # make && make check # make install-strip && make install-configure
# vi /etc/rc.local
添加以下行:
# /usr/local/sbin/authdaemond start
现在,我们安装courier-imap/imaps…
# cd /downloads/qmailrocks/ # tar jxvf courier-imap-4.0.2.tar.bz2 # chown -R bsmith:wheel courier-imap-4.0.2
# cd /downloads/qmailrocks/courier-imap-4.0.2 # subsmith # ./configure --prefix=/usr/local --exec-prefix=/usr/local --withauthvchkpw--without-authldap --without-authmysql --disable-rootcheck--with-ssl --with-authchangepwdir=/usr/local/libexec/authlib --with-redhat # make && make check
我们将退出非root用户,然后回到root。
# Exit # make install-strip && make install-configure # /usr/local/sbin/mkimapdcert # vi /usr/local/etc/imapd.cnf # vi /usr/local/etc/imapd # vi /usr/local/etc/imapd-ssl
# vi /usr/local/etc/authlib/authdaemonrc authmodulelist="authvchkpw“ # cp /usr/local/libexec/imapd.rc /etc/rc.d/init.d/imap # cp /usr/local/libexec/imapd-ssl.rc /etc/rc.d/init.d/imaps
让我们启动Authdaemond,IMAP和IMAPS。
为了安全起见,我们将在启动每项服务之前将其停止。
# /usr/local/sbin/authdaemond stop # /usr/local/sbin/authdaemond start # /etc/rc.d/init.d/imap stop # /etc/rc.d/init.d/imaps stop # /etc/rc.d/init.d/imap start # /etc/rc.d/init.d/imaps start
# telnet localhost 143
Trying 192.168.1.10... Connected to 192.168.1.10. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE STARTTLS] Courier-IMAP ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for distribution information. a login [email protected] theitroad a OK LOGIN Ok. (successful login!) a logout (logs you out) * BYE Courier-IMAP server shutting down a OK LOGOUT completed Connection closed by foreign host.
注意:Courierpassd将要求端口106至少对本地流量开放(来自127.0.0.1的流量)
# cd /downloads/qmailrocks # tar zxvf courierpassd-1.1.0-RC1.tar.gz # cd courierpassd-1.1.0-RC1 # ./configure # make && make install # cd /etc/xinetd.d
其中我们为courierpassd创建xinetd脚本。
# vi courierpassd service courierpassd { port = 106 socket_type = stream protocol = tcp user = root server = /usr/local/sbin/courierpassd server_args = -s imap wait = no only_from = 127.0.0.1 instances = 4 disable = no }
# vi /etc/services
# /etc/rc.d/init.d/xinetd restart Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 200 courierpassd v0.30 hello, who are you? user [email protected] 200 Your password please. pass galaxy 200 Your new password please. newpass galaxy 200 Password changed, thank-you. quit 200 Bye. Connection closed by foreign host.
# telnet localhost 106
步骤12(安装Squirrelmail)
# cd /downloads/qmailrocks # tar xvzf squirrelmail-1.4.8.tar.gz
现在,将未解压缩的文件夹重命名为更友好的名称。
# mv squirrelmail-1.4.8 webmail
现在,我们配置Squirrelmail。
# mkdir /var/sqattachements # chown -R apache:apache /var/sqattachements # cdwebmail # chown -R apache:apache data # cd config # ./conf.pl
常规设置
1. Domain : 1.2.3.4 (Enter the IP of your server here. Don't be an idiot and actually use 1.2.3.4) 2. Invert Time : false 3. Sendmail or SMTP : SMTP
IMAP设定
4. IMAP Server : localhost 5. IMAP Port : 143 6. Authentication type : login 7. Secure IMAP (TLS) : false 8. Server software : other 9. Delimiter : detect
SMTP设置
4. SMTP Server : localhost 5. SMTP Port : 25 6. POP before SMTP : false 7. SMTP Authentication : login 8. Secure SMTP (TLS) : false
我编辑httpd.conf Apache配置文件并添加以下代码块:
<VirtualHost 172.25.25.4:80> ServerName mail.theitroad.com ServerAlias mail.* ServerAdmin [email protected] DocumentRoot /var/www/webmail </VirtualHost>
http://mail.theitroad.com
我们将使用我们早先使用Vqadmin创建的域下的邮局主管帐户登录。
Username: [email protected] Password: theitroad /etc/rc.d/init.d/imap start /etc/rc.d/init.d/imaps start # qmailctl restart # qmailstat
我们已经在CentOS和RHEL上配置了Linux Mail Server Qmail。