Linux OPS advanced article-centos 7 postfix mail Server Setup

Source: Internet
Author: User
Tags anonymous base64 imap openssl administrator password dovecot file permissions squirrelmail

The first chapter of the experimental environment

    1. Hardware environment:
      Linux server one, IP address: 192.168.80.10;
      WIN7 client one, with OUTLOOK2013, test, and server in the same LAN.
    2. Linux system environments, such as:

Chapter II Experimental Content
One: Build a DNS server
Second: Build Postfix server and general
Three: General receiving letter
Four: Certification received
Five: SquirrelMail send and receive mail (build Web mail)
Six: Mail Bulk function configuration
Seven: Mail send capacity size configuration
Eight: Limit user mailbox space by configuring user disk quotas

Chapter III Experimental steps
Preparatory work:
[[email protected] ~]# systemctl stop FIREWALLD//Turn off firewall
[[email protected] ~]# Setenforce 0//Turn off SELinux
Part I: Building a DNS server
[[email protected] ~]# Yum install bind-y//Installation DNS service
------------the following to edit the master configuration file--------------
[Email protected] ~]# vi/etc/named.conf
Modify the following content:

Save exit
[[email protected] ~]# named-checkconf//Check syntax error
Note: If there is an error prompt, read the error prompt, modify the configuration file as prompted, if there is no hint, there is no syntax error.
------------the following to edit the zone configuration file--------------------
[Email protected] ~]# Vi/etc/named.rfc1912.zones
At the end of the file, add the following:

Save exit
[[email protected] ~]# named-checkconf//Check syntax error
Edit the region data profile---------------the following-------------------
[Email protected] ~]# cd/var/named
[Email protected] named]# cp-p named.localhost aa.com.zone
Create a forward zone data profile (note that because I am copying another style file, you must add "-P" when copying the file, which means that the file permissions remain the same when copying).
[[Email protected] named]# VI aa.com.zone//Edit forward zone data profile

(Note the syntax format here, don't miss out ".") )
Save exit
Creating a reverse Zone data configuration file
[Email protected] named]# cp-p named.localhost aa.com.local
[[Email protected] named]# VI aa.com.local//Edit Reverse Zone Data profile

Save exit
[[email protected] named]# named-checkconf//Check syntax error
-------------Start the service, verify the--------------
[[email protected] named]# systemctl start named//Start DNS Service
[[email protected] named]# Systemctl enable named//Set boot up
[[email protected] named]# vi/etc/resolv.conf//Set server domain name

Save exit
[[email protected] named]# nslookup mail.aa.com//parsing verification
Success such as:

The second part: Build postfix and configure basic sending function
[[email protected] ~]# postconf–a//Verify that Cyrus Dovecot feature is supported

(If the postfix has been installed, it will support these two features, if not supported, indicating that Postfix is not installed, CentOS 7 began the default system comes with Postfix. )
[[email protected] ~]# systemctl start postfix start service
------------Edit the Master profile--------------
[Email protected] ~]# VI/ETC/POSTFIX/MAIN.CF
Edit the following content:
Host name of the mail server
Mail domain
Mail field for outgoing mail

Monitor the network card (note that there are spaces between the two addresses)

The object of the service
directory where mail is stored
Save exit
[[email protected] ~]# postfix Check//checking syntax error (same as Named-check usage)
[[email protected] ~]# systemctl restart Postfix//Restart Service
[[email protected] ~]# postconf–n//view postfix non-default and has been in effect configuration
-------------Add a mail test account--------------
[[email protected] ~]# Groupadd mailusers//Create Group to test account
[Email protected] ~]# useradd-g mailusers-s/sbin/nologin Jack
Creating a Jack account belongs only to the Mailusers group and does not log on to the system for testing messages
[[email protected] ~]# passwd Jack//create Jack Password
[Email protected] ~]# useradd-g mailusers-s/sbin/nologin Tom
[Email protected] ~]# passwd Tom
A simple send-to-test--------------The 25 port of the connection server-----------
[[Email protected] ~]# Telnet mail.aa.com 25
Connection successful, start letter
Helo mail.aa.com//Declare the host of this machine
Mail From:[email protected]//Claim Sender Address
RCPT To:[email protected]//Declare recipient address
Data//Write text
I am jack!!
. Body end Tag
Quit//exit


Part III: Verification of receiving letters
Method One: Use ROOT to see if Tom User received a test message
[Email protected] ~]# Cat/home/tom/maildir/new/1515968168.vfd00i306d0f0m475089.localhost.localdomain
Successful display:

Method Two: Build Dovecot to provide the service of receiving credit
--------------Install the Dovecot software----------------
[email protected] ~]# Yum install-y dovecot
---------------Edit the configuration file--------------
[Email protected] ~]# vi/etc/dovecot/dovecot.conf
Modify the following three lines:



Add the following three lines:



Save exit
----------------Start the service--------------
[Email protected] ~]# systemctl start Dovecot
[Email protected] ~]# NETSTAT-ANPT | grep dovecot
110,143 ports need to be monitored

---------------Receiving Verification---------------
[[Email protected] ~]# Telnet mail.aa.com 110
User Tom//Recipient Login
Pass 123//email password
List//Lists view messages
RETR 1//Read messages with a number of 1
Quit//Exit Email



Validation successful
Method Three: Using Win7 client outlook2013 to verify the received message
Open it

Open the upper-left corner, "file"

Click to open Account settings

Open "New",

Manual Setup, next

Select POP or IMAP, next

Configure Tom Information, next

Connection Server succeeded

Complete

Click "All Folders" on the left, Tom account is logged in

Click "Inbox" and Tom has successfully received the message

Validation successful
Note: If the reception is slow, click on the upper right corner to receive

Part IV: Sending authentication configuration

  1. Edit Authentication Profile
    ---------install CYRUS-SASL software-------------
    [[email protected] ~]# yum install-y CYRUS-SASL // Note that this adds "", which contains the plugins included in the Software installation
    ----------Edit Profile---------------
    [[email protected] ~]# vi/etc/sasl2/ SMTPD.CONF
    //Configure authentication Mode
    Save Exit
    [[email protected] ~]# VI/ETC/SYSCONFIG/SASLAUTHD
    //local user authentication
    Save exit
    -------------Start the service--------------
    [[email protected] ~]# systemctl start SASLAUTHD
    [[email protected ] ~]# systemctl Enable SASLAUTHD
  2. Edit the postfix master configuration file
    [Email protected] ~]# VI/ETC/POSTFIX/MAIN.CF
    Add the following content:
    Smtpd_sasl_auth_enable = yes//enable authentication
    Smtpd_sasl_security_options = noanonymous//Do not allow anonymous sending
    Mynetworks = 127.0.0.0/8//Allowed network segment, if you increase the network segment of the machine will appear to allow non-authentication can also be sent to the other country
    Smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination// Allow the local domain and the successful certification of the letter, refused to fail the certification of the letter


    [[email protected] ~]# postfix Check//checking syntax error
    [[email protected] ~]# systemctl restart Postfix//restart Postfix service
  3. Test Common letter Verification

    Note: Because [email protected] is not authenticated, access is denied and delivery fails
  4. Generate a ciphertext for a mail user name and password
    [[email protected] ~]# printf "Jack" | OpenSSL base64//Account Encryption
    [[email protected] ~]# printf "123" | OpenSSL base64//password encryption
  5. Character Terminal test certificate
    [[Email protected] ~]# Telnet mail.aa.com 25
    EHLO mail.aa.com//Note is EHLO not helo
    AUTH Login//Authentication Login
    amfjaw==//Ciphertext user name
    Mtiz//Ciphertext password
    Mail From:[email protected]
    RCPT To:[email protected]
    Data
    This is test
    .
    Quit
    Sent successfully
  6. Win7 Client with outlook2013 test authentication
    Change account Configuration

    Open "Other Settings".

    Send the server, hit √, use the same settings as the receiving mail server

    Next, success

    New e-mail

    Write

    See if Jack has received a message
    Outlook adds the Jack account, as with the Add Tom Method, remember to play √ in other settings

    Validation successful

Part V: Configure SquirrelMail Send and receive mail (small squirrel web browsing mailbox)
---------------Build Lamp Environment-------------

  1. Installing the httpd,mariadb,php Service
    Yum install-y \
    HTTPD \//apache Service
    Mariadb-server mariadb \//mysql Service
    PHP \//php Services
    PHP-MYSQL \//php Association Database
    PHP-GD \
    libjpeg* \
    PHP-LDAP \
    PHP-ODBC \
    Php-pear \
    Php-xml \
    PHP-XMLRPC \
    Php-mhash
  2. Edit Apache master configuration file
    [Email protected] ~]# vi/etc/httpd/conf/httpd.conf
    Domain name

    Save exit
  3. Edit PHP Master configuration file
    [Email protected] ~]# Vi/etc/php.ini

    Save exit
  4. Start the service
    [[email protected] ~]# systemctl start httpd//Start Apache Service
    [[email protected] ~]# Systemctl enable httpd//Set boot up
    [[email protected] ~]# systemctl start mariadb//start MySQL database service
    [[email protected] ~]# Systemctl enable MARIADB//Set boot up
    [Email protected] ~]# NETSTAT-ANPT | grep 80//view httpd port status

    [Email protected] ~]# NETSTAT-ANPT | grep 3306//view MySQL port status
  5. Web Test http://192.168.80.10/
  6. Edit MySQL Database Security configuration
    [Email protected] ~]# mysql_secure_installation

    Enter using local Administrator root

    Create a database administrator password, enter, input two times password (123)

    Remove Anonymous Users

    Do not allow administrator to log on remotely, select No

    To delete a test database

    Reload Permissions Configuration
  7. editing PHP Test files
    [Email protected] ~]# vi/var/www/html/index.php
    Create a PHP default configuration file and add the following:

    Save exit
    Web Test http://192.168.80.10/

    Test success
  8. Edit MySQL Database
    Enter the database to create an authorized account
    [Email protected] ~]# mysql-u root–p
    Enter the database password (123), enter enter the following content

    Test that the database is working properly
    [Email protected] ~]# vi/var/www/html/index.php
    Delete the other content and enter the following:

    Save exit
    Refresh Web page

    Test success
    ----------------Build a squirrel Web mailbox--------------
  9. Preparatory work
    http://www.squirrelmail.org/download.php
    Go to the website to download the compressed package to the Linux server
    Installation package:
    Chinese-Typed package:
  10. Extract
    [Email protected] ~]# tar xzvf squirrelmail-webmail-1.4.22.tar.gz
    Unzip the installation package to generate an installation file
    [Email protected] ~]# tar xzvf all_locales-1.4.18-20090526.tar.gz-c squirrelmail-webmail-1.4.22
    Unzip the package into the installation file

    [Email protected] ~]# CP-RV Squirrelmail-webmail-1.4.22/var/www/html/mail
    Copy the file to the HTTP default directory
    [Email protected] ~]# cd/var/www/html/mail/
  11. Create a small Squirrel Web page default configuration file
    [Email protected] mail]# mkdir attach
    [Email protected] mail]# chown-r Apache:apache attach/data/
    [[Email protected] mail]# CD Config
    [email protected] config]# CP config_default.php config.php
  12. Editing a configuration file
    [Email protected] config]# VI config.php
    Modify the following content:
    $domain = ' aa.com '; Domain name
    $imap _server_type = ' dovecot '; Service type
    $data _dir = '/var/www/html/mail/data '; Data Catalog
    $attachment _dir = '/var/www/html/mail/attach/'; Accessories Catalogue
    $squirrelmail _default_language = ' ZH_CN '; Default language environment
    $default _charset = ' zh_cn. UTF-8 '; Default character encoding
    Save exit
    Note Special characters, "$" and ";" Don't miss out.
  13. Web Validation Test Http://192.168.80.10/mail

    Enter the jack or Tom account password to log in

    Validation successful

Part VI: Mass mailing configuration

    1. Set up a mail group
      [Email protected] ~]# vi/etc/aliases
      Add the following content:

      Add Jack,tom to the student group
      Save exit
      [[email protected] ~]# newaliases//Generate a new hash database file
    2. Restart Postfix Service
      [[email protected] ~]# systemctl restart Postfix/restart Postfix service
    3. Add a Lucy Mail test user
      [Email protected] ~]# useradd-g mailusers-s/sbin/nologin Lucy
      [Email protected] ~]# passwd Lucy
    4. Login to outlook2013, login to Lucy account, send bulk mail to student group
      Add a Lucy account in Outlook
      Send a letter with Lucy's account

View Tom and Jack account receipt
Jack successfully received the letter

Tom successfully received the letter

Validation successful

Part VII: Sending message capacity size limits
------------Edit the configuration file--------------
[[email protected] ~]# vi/etc/postfix/main.cf//edit postfix configuration file
Finally add the following content:

Limit the maximum size of messages sent to 5MB
Save exit
[[email protected] ~]# systemctl restart Postfix//restart Postfix service
--------------------Verify with Outlook----------------------
Send a file with more than 5M



Send failed, validation successful

Part VIII: Restrict user mailbox space by configuring user disk quotas
-----------disk quotas are turned on------------
[[email protected] ~]# DF–HT//View message directory mount information

[Email protected] ~]# Vi/etc/fstab
Modify the configuration file to enable automatic mount on boot
Modify the following content:

Save exit
[[email protected] ~]# mount//view SDA2 disk quota open Status

[[email protected] ~]# umount/home///Uninstall home directory
[[email protected] ~]# mount–a//re-mount
[[email protected] ~]# mount//View mount status

Mount succeeded
[Email protected] ~]# quotaon-p/home/
Confirm that the home directory disk quota is turned on

Disk quotas are automatically turned on by default because the SDA2 partition format is XFS
--------------Configure the disk quota limit for the Jack user---------------
[Email protected] ~]# edquota-u Jack

Configure Jack user mailbox size to 10M max
-------------test, verify--------------
Remove the message sending size limit
[Email protected] ~]# VI/ETC/POSTFIX/MAIN.CF
Delete the following content:

Save exit
[[email protected] ~]# systemctl restart Postfix//Restart Service
Send a message to jack with Outlook


After the third message is issued, the mailbox prompt, the hard disk quota overflows
[Email protected] ~]# cd/home/jack/maildir/cur/
Enter the directory where the jack user holds the message to see the size of the received message

The system received two messages by default, the capacity has reached 7.1M, can not receive the third 3M of mail, disk quotas effective, test success!!

Linux Operations Advanced article-centos 7 postfix mail Server Setup

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.