Another disadvantage of "Postfix", which is widely used in mail services, is much less, or it is designed to address the shortcomings of sendmail. Corresponding to the shortcomings of SendMail, it is also relatively mature in all aspects. Therefore, there is no special requirements, it is not recommended to use SendMail to build mail servers. This site describes the mail server configuration method, will also be based on Postfix.
Verify that the addition of the MX record is effective:
The code is as follows |
Copy Code |
[Root@sample ~]# host-t mx centospub.com Centospub.com Mail is handled by mail.centospub.com. Confirm MX record takes effect |
Then install Postfix
The code is as follows |
Copy Code |
[Root@sample ~]# yum-y install postfix online installation postfix |
Configuring the Postfix
The code is as follows |
Copy Code |
[Root@sample ~]# vi/etc/postfix/main.cf edit postfix configuration file #myhostname = Host.domain.tld finds this row, overwriting the portion following the equals sign as host name Myhostname = sample.centospub.com changed to this state, set the system's host name #mydomain = Domain.tld Find this row, overwriting the part following the equal sign as a domain name MyDomain = centospub.com changed to this state, setting the domain name (we will let this be set to the part following the e-mail address "@") #myorigin = $mydomain Find this line and remove the # from the beginning of the line Myorigin = $mydomain changed to this state, set the section following the address "@" to the domain name (non-system host name) Inet_interfaces = localhost find this row, change "localhost" to "all" Inet_interfaces = All becomes this state, accepting requests from all networks mydestination = $myhostname, localhost. $mydomain, localhost find this row, add "$mydomain" to the behavior mydestination = $myhostname, localhost. $mydomain, localhost, $mydomain changed to this state, specify the domain name to send to local mail #relay_domains = $mydestination Find this line and remove the # from the beginning of the line Relay_domains = $mydestination becomes this state, defining the domain name that is allowed to be forwarded #mynetworks = 168.100.189.0/28, 127.0.0.0/8 to find this trip, according to their own internal circumstances modified Mynetworks = 168.100.189.0/28, 127.0.0.0/8 into this state, specify intranet and local IP address range #home_mailbox = maildir/Find this line and remove the # from the beginning Home_mailbox = maildir/changed to this state, specify user mailbox directory # show SOFTWARE VERSION OR not # # The Smtpd_banner parameter specifies the text that follows the 220 # code in the SMTP server ' s greeting banner. Some people like to # The mail version advertised. By default, Postfix shows no version. # # You must specify $myhostname at the start of the text. That's an # RFC requirement. Postfix itself does not care. # #smtpd_banner = $myhostname ESMTP $mail _name #smtpd_banner = $myhostname ESMTP $mail _name ($mail _version) finds this line, and then adds the following line: Smtpd_banner = Add this line $myhostname ESMTP unknow, do not display information about the SMTP server At the end of the configuration file, add the following line: smtpd_sasl_auth_enable = yes server uses SMTP authentication Smtpd_sasl_local_domain = $myhostname Specify the SMTP authenticated local domain name (hostname) Smtpd_sasl_security_options = noanonymous does not allow anonymous authentication Smtpd_recipient_restrictions = Permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination Message_size_limit = 15728640 The maximum size of the message is 15MB |
2, configure the SMTP authentication related options
In order to improve security, we do not use the system user's password as the corresponding user's SMTP authenticated password, but will then establish the SMTP authentication-specific password for the user later.
The code is as follows |
Copy Code |
[Root@sample ~]# vi/usr/lib/sasl2/smtpd.conf Edit SMTP-certified configuration file Pwcheck_method:saslauthd find this line, change "SASLAUTHD" to "Auxprop" Pwcheck_method:auxprop does not use the system user password as the user's SMTP authentication password [Root@sample ~]# VI/ETC/SYSCONFIG/SASLAUTHD Mech=shadow found this line, in front Plus # #MECH =shadow do not use shadow mechanism Flags= find this row and add "Sasldb" after the equals sign Flags=sasldb definition authentication method is SASLDB2
|
3, the establishment of user's mailbox directory
First, the mailbox directory under the user template is established so that when the new user is created, the corresponding user's mailbox directory is automatically established.
The code is as follows |
Copy Code |
[Root@sample ~]# mkdir/etc/skel/maildir Create user's mailbox directory under User templates [Root@sample ~]# chmod 700/etc/skel/maildir Set User mailbox Directory property to 700
|
Then create a corresponding project for the user who already exists. Www.111cn.net
The code is as follows |
Copy Code |
[Root@sample ~]# Mkdir/home/centospub/maildir to create a mailbox directory for the user (here for example centospub user) [Root@sample ~]# chmod 700/home/centospub/maildir Set the user mailbox directory property to 700 [Root@sample ~]# chown centospub. /home/centospub/maildir set the user's mailbox directory for this user all |
4, set the SMTP authentication password for the user
The code is as follows |
Copy Code |
[Root@sample ~]# saslpasswd2-u sample.centospub.com-c centospub Set SMTP authentication password for centospub users Password: Enter the password here (not shown) Again (for verification): Enter password again |
5, change the property and attribution of Sals
The code is as follows |
Copy Code |
[Root@sample ~]# chgrp postfix/etc/sasldb2 to change the database ownership to Postfix, [Root@sample ~]# chmod 640/etc/sasldb2 To change database properties to 640 |
6, turn off the SendMail service and set the default MTA
Because we are not prepared to use SendMail as an SMTP server with Postfix, we turn off the SendMail service to ensure security and conserve system resources.
The code is as follows |
Copy Code |
[Root@sample ~]#/etc/rc.d/init.d/sendmail stop shutdown sendmail Service Shutting down SendMail: [OK] Shutting down sm-client: [OK] [Root@sample ~]# chkconfig sendmail off sendmail from boot [Root@sample ~]# chkconfig–list SendMail confirm that the SendMail has been turned off (all off OK) SendMail 0:off 1:off 2:off 3:off 4:off 5:off 6:off |
The default MTA is then set to Postfix.
The code is as follows |
Copy Code |
[Root@sample ~]# alternatives–config MTA set default MTA There are 2 programs which provide ' MTA '. Selection Command ———————————————– 1/usr/sbin/sendmail.sendmail Current Status: SendMail is default MTA 2/usr/sbin/sendmail.postfix Enter to keep the current selection[+], or type selection number: |
2 Enter 2 here to make Postfix the default MTA
Start the appropriate service
Finally, start the SMTP authentication and Postfix service, and set the appropriate service to start from.
code is as follows |
copy code |
[root@sample ~]# Chkconfig SASLAUTHD set on to self-boot] [ root@sample ~]# chkconfig –list saslauthd 确认SMTP-Auth服务状态 saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off& nbsp; confirm that the 2~5 on is OK [root@sample ~]#/etc/rc.d/init.d/saslauthd start start Smtp-auth Starting saslauthd: [OK] [root@sample ~]# chkconfig postfix on set Postfix to start from [Root@sample ~]# Chkcon Fig–list postfix confirm the Postfix service status postfix 0:off 1:off 2:on 3:on the 4:on 5:on 6:off confirm that the status of 2~5 is on ok [root@sample ~]#/etc/rc.d/init.d/postfix start start postfix Starting postfix: [OK] |
This completes the configuration of the SMTP server, but currently has only the ability to send mail from the standby client through the server. As a complete mail server, you also need to have the ability to accept messages from the client through the POP/IMAP protocol to the Local.