Postfix Server Setup

Source: Internet
Author: User
Tags syslog dnssec dovecot install perl nslookup vmail

Implement Postfix implementation Extmail interface

Environment:

Host 1:172.16.115.169 (DNS server)

Host 2:172.16.115.161 (mail server)

On Host 1:

1. Build a DNS server

Yum install-y bind

1.1 Edit Master configuration vim /etc/named.conf

# Listen to all IP on the machine, allow the client to query

Options {

listen-on Port : (any;};

Listen-on-v6 Port 53 {:: 1;};

Directory "/var/named";

Dump-file "/var/named/data/cache_dump.db";

Statistics-file "/var/named/data/named_stats.txt";

Memstatistics-file "/var/named/data/named_mem_stats.txt";

allow-query { any;};

recursion Yes;

Dnssec-enable Yes;

Dnssec-validation Yes;

1.2 Edit Domain profile vim /etc/named.rfc1912.zones

#正向解析和反向解析

Zone " huangzp2.com "in {

Type master;

file " huangzp2.com ";

allow-update {none;};

};

Zone " 115.16.172. In-addr.arpa "in {

Type master;

file " Huangzp2.empty ";

allow-update {none;};

};

1.3 Editing a data configuration file

cd/var/named/

1.3.1 Forward parsing data records

Cp-p Named.localhost huangzp2.com

Or

CP Named.localhost Huangzp2.com;chown named huangzp2.com

Vim huangzp2.com

# Add forward parse record

$TTL 1D

@ in SOA huangzp2.com. Rname.invalid. (

0; Serial

1D; Refresh

1H; Retry

1W; Expire

3H); Minimum

NS dns.huangzp2.com.

MX 3 mail.huangzp2.com.

DNS A 172.16.115.169

Mail A 172.16.115.161

1.3.2 Reverse parsing data records

Cp-p Named.empty Huangzp2.empty

Vim Huangzp2.empty

# Anti-parsing record

$TTL 3H

@ in SOA huangzp2.com. Rname.invalid. (

0; Serial

1D; Refresh

1H; Retry

1W; Expire

3H); Minimum

NS dns.huangzp2.com.

169 PTR dns.huangzp2.com.

161 PTR mail.huangzp2.com.

2. Start named

Service named restart


On Host 2:

1. Test mail Domain resolution

Vim/etc/sysconfig/network-scripts/ifcfg-eth0

# Setting up a DNS server

Device=eth0

hwaddr=00:0c:29:cb:db:6c

Type=ethernet

uuid=05904c7e-119a-4e58-8b65-26d344366982

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=172.16.115.161

netmask=255.255.0.0

gateway=172.16.0.199

dns1=172.16.115.169

dns=202.96.134.133

# Test forward parsing

[email protected] docs]# nslookup mail.huangzp2.com

server:172.16.115.169

address:172.16.115.169#53

Name:mail.huangzp2.com

address:172.16.115.161

# Test Reverse resolution

[email protected] docs]# nslookup 172.16.115.161

server:172.16.115.169

address:172.16.115.169#53

161.115.16.172.in-addr.arpa name = mail.huangzp2.com.

2. Installation Kit

Yum install-y MySQL mysql-server mailx

Service mysqld Start

3. Installing Extmail and Extman

Download extmail-1.2.tar.gz

Extman-1.1.tar.gz

Extract

TAR-ZXF extmail-1.2.tar.gz-c/var/www/extsuite/

TAR-ZXF extmman-1.1.tar.gz-c/var/www/extsuite/

Renamed

MV extmail-1.2 Extmail

MV extman-1.1 Extman

4. Import the database template file

Enter directory:

/var/www/extsuite/extman/docs

4.1 Copy configuration file:

CP mysql_virtual_alias_maps.cf/etc/postfix/

CP mysql_virtual_domains_maps.cf/etc/postfix/

CP mysql_virtual_mailbox_maps.cf/etc/postfix/

CP mysql_virtual_sender_maps.cf/etc/postfix/

4.2 Modifying the database initial data:

Vim/var/www/extsuite/extman/docs/init.sql

# Replace domain name

: 1, $s/extmail.org/huangzp2.com/g

# Change Password

INSERT into ' manager ' VALUES (' [email protected] ', '123456', ' admin ', ' root ', ' Super User ', ' my Question ', ' My Answer ', ' 0 ', ' 2007-02-14 15:10:04 ', ' 2010-11-08 ', 1);

4.3 Importing a database template

MySQL < Extmail.sql

MySQL < Init.sql

5. Create virtual user mappings for real users

Useradd-u Vmail

6. Modify the main postfix configuration file

Vim/etc/postfix/main.cf

# Service to all addresses

Inet_interfaces = All

#inet_interfaces = $myhostname

#inet_interfaces = $myhostname, localhost

#inet_interfaces = localhost

# Enable IPv4, and IPV6 if supported

Inet_protocols = All

# The location where the message is saved; The user and group ID used to receive the message; Add the specified configuration file

virtual_mailbox_base = /home/vmail

virtual_uid_maps = static:600

virtual_gid_maps = static:600

Virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

Virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

Virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

7. Start Postfix

Service Postfix start

Netstat-anpt

8. e-mail test

to send a message:

echo "HI" |mail-s test [email protected]

To view the contents of the generated catalog:

# support is an alias for postmaster

Ls/home/vmail/huangzp2.com/postmaster/maildir/new

9. Installing and configuring Dovecot (MRA)

Description: Provide a search function

Yum install-y dovecot Dovecot-mysql

9.1 Modifying the configuration file:

vim/etc/dovecot/conf.d/10-mail.conf

# Set the location for receiving messages

mail_location = Maildir:/home/vmail/%d/%n/maildir

# The virtual user ID number of the receiving message starts at 600

First_valid_uid = 600

9.2 Modifying the configuration file:

vim/etc/dovecot/conf.d/10-auth.conf

# Receive Email authentication method database Authentication

!include Auth-system.conf.ext

!include Auth-sql.conf.ext

9.3 Copy and edit the database validation template configuration file

cp/usr/share/doc/dovecot-2.0.9/example-config/dovecot-sql.conf.ext /etc/dovecot

Edit the configuration file:

Vim/etc/dovecot/dovecot-sql.conf.ext

# Set Database type is MySQL

Driver = MySQL

# Connection to the database and default encryption method

Connect = host=localhost dbname=extmail user=extmail password=extmail

Default_pass_scheme = MD5

# Ways to query passwords and users

Password_query = \

SELECT username, domain, password \

From mailbox WHERE username = '%u ' and domain = '%d '

User_query = SELECT Maildir, as UID, as GID from mailbox WHERE username = '%u '

9.4 Start Dovecot

Service Dovecot Start

10. Test for receiving mail

Description: Indicates that Dovecot is able to authenticate with MySQL (Postmaser user's username and password) only if the authentication is successful, it can log in and view the contents of the message.

[[email protected] docs]# telnet mail.huangzp2.com

Trying 172.16.115.161 ...

Connected to mail.huangzp2.com.

Escape character is ' ^] '.

+ok Dovecot ready.

User [email protected]

+ok

Pass Extmail

+ok logged in.

List

+ok 2 messages:

1 533

2 530

11. Installing and configuring the Web server

Yum Install-y httpd

11.1 Editing a configuration file

Vim/etc/httpd/conf/httpd.conf

# Turn on the virtual host

Namevirtualhost *:80

# Invoke scripts, set directory aliases, invoke scripts to run users and groups

<virtualhost *:80>

documentroot /var/www/extsuite/extmail/html

ServerName mail.huangzp2.com

scriptalias/extmail/cgi/var/www/extsuite/extmail/cgi

Alias/extmail/var/www/extsuite/extmail/html

scriptalias/extman/cgi/var/www/extsuite/extman/cgi

Alias/extman/var/www/extsuite/extman/html

Suexecusergroup Vmail Vmail

</VirtualHost>

12. Set the CGI directory permissions for Extmail and edit the configuration file

# permissions; Change template profile to master configuration profile

Cd/var/www/extsuite/extmail

Chown-r Vmail.vmail cgi/

CP Webmail.cf.default WEBMAIL.CF

Editing a configuration file

vim/var/www/extsuite/extmail/webmail.cf

#设置邮件的基本目录; encryption type; user and password for database

Sys_maildir_base = /home/vmail

Sys_crypt_type = Plain

Sys_mysql_user = Extmail

Sys_mysql_pass = Extmail

13. Set the CGI directory permissions for Extman and edit the configuration file

Cd/var/www/extsuite/extman

Chown-r Vmail.vmail cgi/

CP Webman.cf.default WEBMAN.CF

Encryption method; basic home directory; temporary session Directory; Check code

Sys_crypt_type = Plain

Sys_maildir_base = /home/vmail

Sys_sess_dir = /tmp/

sys_captcha_on = 0

14. Client Test parsing

Start httpd

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8C/EF/wKiom1h-MHOS98iRAABX-kjN1kU625.png-wh_500x0-wm_ 3-wmp_4-s_2426067211.png "style=" Float:none; "title=" Afd.png "alt=" Wkiom1h-mhos98iraabx-kjn1ku625.png-wh_50 "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8C/EC/wKioL1h-MHTRNeEaAAAVMQCoQOs153.png-wh_500x0-wm_ 3-wmp_4-s_3230176835.png "style=" Float:none; "title=" Sdafda.png "alt=" wkiol1h-mhtrneeaaaavmqcoqos153.png-wh_50 "/ >

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

15. Compile and install the Unix-syslog module

Yum Install perl-cgi gcc*

Unix-syslog-1.1.tar.gz

TAR-ZXF unix-syslog-1.1.tar.gz

CD unix-syslog-1.1

# The module is written in Perl and needs to be installed in Perl

Perl makefile.pl

Make Test

Make install

16. Client Testing:

Browser:http://mail.huangzp2.com/extmail/cgi/index.cgi

Email Login

Default User name: Postermaster

Default Password: Password extmail

Mailbox Management Login

Default User name:[email protected]huangzp2.com

Default password: 123456

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/8C/EC/wKioL1h-Mi6Si4HaAAF9ts8qQ5M362.png "style=" float : none; "title=" Ewffffff.png "alt=" Wkiol1h-mi6si4haaaf9ts8qq5m362.png "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/8C/EF/wKiom1h-Mi_AriH9AACuqg0z6IU313.png "style=" float : none; "title=" 122222222.png "alt=" Wkiom1h-mi_arih9aacuqg0z6iu313.png "/>


Postfix Server Setup

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.