Create a department email server using Qmail in Linux

Source: Internet
Author: User
Tags qmail
Article Title: Use Qmail in Linux to create a department email server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   I. installation environment
Installation Platform: RedHat Linux 7.3
Installed machine: mail.mydomain.com
Software Package:
Qmail-1.03 qmail Basic System
Ucspi-tcp-0.88 services such as tcpsever
Daemontools-0.76 monitoring tools
Checkpassword-0.90 pop3 USER verification program
Software Source:
Http://www.qmail.org
Http://cr.yp.to/
Http://inter7.com/main.html
Note: You must carefully read the INSTALL and FAQ before installing each package. You can solve many problems in the FAQ.
  
   Ii. Installation Steps
1. Preparations
Delete sendmail
# Rpm-e -- nodeps sendmail
2. Install qmail
1) create a qmail installation directory
# Mkdir/var/qmail
2) Add users and groups required for qmail
# Groupadd nofiles
# Useradd-g nofiles-d/var/qmail/alias
# Useradd-g nofiles-d/var/qmail qmaild
# Useradd-g nofiles-d/var/qmail qmaill
# Useradd-g nofiles-d/var/qmail qmailp
# Groupadd qmail
# Useradd-g qmail-d/var/qmail qmailq
# Useradd-g qmail-d/var/qmail qmailr
# Useradd-g qmail-d/var/qmail qmails
3) decompress, unpackage, and compile
(Assume that all these packages are downloaded to the/tmp directory)
# Cd/tmp
# Tar xzvf qmail-1.03.tar.gz
# Cd qmail-1.03
Go to the qmail directory, read the README and INSTALL files carefully, and then compile qmail.
Patch DNS
# Vi dns. c
Jump to line 24 and change PACKETSZ to 65536.
# Make setup check
4) Configuration
#./Config
Or
#./Config-fast mail.mydomain.com
5) Create a system alias
# (Cd/var/qmail/alias; touch. qmail-postmaster. qmail-mailer-daemon. qmail-root)
# Chmod 644 ~ Alias/. qmail *
You can specify a management user in these alias files to receive these system emails, as shown in figure
# Echo admin> ~ Alias/. qmail *
6) Create the Startup File and the user's Maildir
Note: I prefer to change Maildir to. Maildir to hide the column directory.
# Cp-p/var/qmail/boot/home/var/qmail/rc
# Chmod 755/var/qmail/rc
Edit/var/qmail/rc
Change./Mailbox to./. Maildir to support pop receiving mode of maildir, as shown below:
#! /Bin/sh
# Using splogger to send the log through syslog.
# Using qmail-local to deliver messages ~ /Maildir by default.
Exec env-PATH = "/var/qmail/bin: $ PATH" qmail-start./. Maildir
Delete the splogger qmail command and use multilog later.
You have created maildir:
$/Var/qmail/bin/maildirmake ~ /. Maildir
$ Echo./. Maildir/> ~ /. Qmail
Create maildir (for users to be created later ):
#/Var/qmail/bin/maildirmake/etc/skel/. Maildir
# Echo./. Maildir/>/etc/skel/. qmail
7) delete a temporary directory
# Rm-rf/tmp/qmail-1.03
3. Install ucspi-tcp-0.88
# Tar zxvf ucspi-tcp-0.88.tar.gz
# Cd ucspi-tcp-0.88
# Make
# Make setup check
The execution file will be installed in/usr/local/bin.
  
4. Install checkpassword
# Tar zxvf checkpassword-0.90.tar.gz
# Cd checkpassword-0.90
# Make
# Make setup check
# Chmod og-rx/bin/checkpassword
The execution file checkpassword will be installed in/bin.
If you do not open mail to users in/etc/passwd, you do not need to install checkpassword, but you only need to install vpopmail.
  
5. Security? Daemontools
# Mkdir-p/package
# Chmod 1755/package
# Cd/package
  
# Tar-xvzf daemontools-0.76.tar.gz
# Cd admin/daemontools-0.76
  
# Package/install
  
Comment out the svscanboot of the last line in the/etc/inittab.
Restart: # kill-HUP 1
Note: modifying the inittab is your preferred choice.
6. Create SMTP forwarding rules
1) Create/etc/tcp. smtp
? Hot Swap? : Allow"
# Echo ": allow">/etc/tcp. smtp
This is to accept any sub-forwarding letter sent by the Client.
To reject Relay from some IP addresses, modify/etc/tcp. smtp as follows:
192.10.10.: allow, RELAYCLIENT = ""
127.: allow, RELAYCLIENT = ""
In this way, all addresses except 192.10.10. * and 127. * will be rejected for the transfer.
2) convert tcp. smtp to the cdb format
#/Usr/local/bin/tcprules/etc/tcp. smtp. cdb/etc/tcp. smtp. tmp </etc/tcp. smtp
Note: any changes to tcp. smtp are required? It takes effect only when tcprules is converted to a cdb file.
In addition, if tcp. smtp is blank, all transfers are rejected because the preset rule is deny.
Now, the forwarding rule has been set up and qmail-smtpd will be started according to this rule later.
7. Create a startup system service script
1) create a LOG directory
# Mkdir/var/log/qmail
# Chown qmaill. nofiles/var/log/qmail
# Mkdir/var/log/qmail/smtpd
# Chown qmaill. nofiles/var/log/qmail/smtpd
# Mkdir/var/log/qmail/pop3d
# Chown qmaill. nofiles/var/log/qmail/pop3d
  
2) Set services
Remove smtp and pop3 settings in inetd. conf (plus)
NOTE: If redhat7.3 replaces inetd with xinetd, you do not need to change it.
Edit/etc/services and confirm the following settings (the actual order is not as follows ):
Smtp 25/tcp mail
# Pop-3 110/tcp # pop version 3
# Pop-3 110/udp
POP3. 110/tcp
Pop3 110/udp
3) write the send/smtpd/pop3d supervise script run
# Cd/var/qmail
# Mkdir-p supervise/qmail-send/log
# Mkdir-p supervise/qmail-smtpd/log
# Mkdir-p supervise/qmail-pop3d/log
# Cd supervise/qmail-send
# Ln-s/var/qmail/rc run
Other run content is as follows:
Qmail-send/log/run:
#! /Bin/sh
Exec/usr/local/bin/setuidgid qmaill/usr/local/bin/multilog t/var/log/qmail
Qmail-smtpd/run:
#! /Bin/sh
QMAILUID = 'id-u qmaild'
QMAILGID = 'id-g qmaild'
Exec/usr/local/bin/tcpserver-v-p-x/etc/tcp. smtp. cdb-u $ QMAILUID-g $ QMAILGID 0 smtp/var/qmail/bin/qmail-smtpd 2> & 1
Qmail-smtpd/log/run:
#! /Bin/sh
Exec/usr/local/bin/setuidgid qmaill/usr/local/bin/multilog t/var/log/qmail/smtpd
Qmail-pop3d/run:
#! /Bin/sh
Exec/usr/local/bin/fig-v-R 0 pop3/var/qmail/bin/qmail-popup mail.mydomain.com/bin/checkpassword/var/qmail/bin/qmail-pop3d. maildir 2> & 1
Qmail-pop3d/log/run:
#! /Bin/sh
Exec/usr/local/bin/setuidgid qmaill/usr/local/bin/multilog t/var/log/qmail/pop3d
4) self-built STARTUP script/etc/init. d/qmail
The content is as follows:
#! /Bin/bash
# Chkconfig: 2345 96 6
#
######################################## ##############################
# Description: Script to control qmail process #
# File:/etc/rc. d/init. d/qmail #
######################################## ##############################
# Setup environment for script execution
  
./Etc/rc. d/init. d/functions
  
PATH = $ PATH:/var/qmail/bin:/usr/local/bin
Export PATH
  
SVSCANPID = "/var/run/svscan. pid"
  
StopQmail (){
If [-f $ SVSCANPID]; then
Kill 'cat $ SVSCANPID'
Rm-f $ SVSCANPID
Fi
  
Svc-dx/var/qmail/supervise/qmail-pop3d/log
Svc-dx/var/qmail/supervise/qmail-pop3d
  
Svc-dx/var/qmail/supervise/qmail-smtpd/log
Svc-dx/var/qmail/supervise/qmail-smtpd
  
Svc-dx/var/qmail/supervise/qmail-send/log
Svc-dx/var/qmail/supervise/qmail-send
}
  
Case "$1" in
Start)
Echo "Starting qmail/smtp/pop3 ..."
Cd/var/qmail/supervise
Env-PATH = "$ PATH" svscan &
Echo $! > $ SVSCANPID
;;
  
Stop)
Echo "Stoping qmail/smtp/pop3 ..."
StopQmail
;;
  
Restart)
$0 stop
$0 start
;;
  
Status)
;;
  
*)
Echo "Usage: $0 {start | stop | status }"
Exit 1
Esac
  
Exit 0
  
Add to chkconfig Management
# Chmod 755 qmail.com
# Chkconfig-add qmail
Run ntsysv to close or start the service
  
   Iii. tips
1. Use the name in the form of userName@mydomain.com
# Cd/var/qmail/alias
# Echo mydomain.com> locals
2. Change the password
For mail-only users, change shell to passwd.
# Useradd-s/usr/bin/passwd userName
Then use telnet to change the password
3. qmail1.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.