& Lt; MAIL service postfix + mysql & gt; MAIL Article 2

Source: Internet
Author: User

 

Environment: this service is based on the first article. It is best to build the first article.

 

The premise of using this service is that your system has installed the msql and postfix services.

Postfix + mysql is mainly used in combination with mysql for sending mail services. Of course, it is not very convenient for mysql to be used in the command line. Let's take a look at the usage of mysql in linux graphical mode:

The following software package.

PhpMyAdmin-2.11.3-all-languages.tar.gzIs phpApacheManage mysql through web pages.

Since the web page is used to manage mysqlOf course, you must put the directory of this software package into apahce.Next, right

I downloaded the package directly to/var/www/html.Below. Decompress the package

First, decompress the package. The package name is long. You can change it to a short name.

# Phpmyadmin mv phpMyAdmin-2.11.3-all-languages

Switch to this directory

Then we can check the installation steps:

[Root @ rhce phpmyadmin] # vim INSTALL

 

PhpMyAdmin-Installation

-------------------------

The Installation File prompts us to see the 2Files.

Please have a look to the Documentation.txt or

Documentation.html files.

Open documentation.txt.File.

Vim Documentation.txt

Find Quick Install

Step 4: 4. Now you must configure your installation. There are two methods that can be

Used. Traditionally, users have hand-edited a copy of config. inc. php,

Now a wizard-style setup script is provided for those who prefer

Graphical installation. Creating a config. inc. php file is still a quick way

To get started and needed for some advanced features. Which of the following files should be written in English?

The meaning of this paragraph: 2Method: You can use an existing file to copy a config. inc. php file.. Or create a config. inc. phpIf you create the file by yourself, the following content will be written to the file:

 

We copy one:

# Cp config. sample. inc. php config. inc. php

For more information about the modifications, see Step 4. Although we copy the modifications, we only need the template and the content should be the same as what we have created.

Open config. inc. phpFile. By default, the red part is empty. We will install it quickly and copy the following code to paste it.

$ Cfg ['blowfish _ secret'] = 'ba17c1ec07d65003 ';/* you must fill in this for cookie auth! */

ApacheNow that the service is ready, we need to install phpSoftware Package:

# Yum install php-mysql-y //InstallPhpOne is not enough.Php-mysql.

RestartMysqlAndHttpdService:

Enter the following in the browser:Ip/phpmyadminPress enter.OK.

 

Then you will see the following interface, where you can select Chinese. Log on to yourMysqlDatabase.

 

Then I createWestosLibrary andDateTable. The database and table names can be used as needed. You do not have to write them as per me.

The table structure consists of four parts:

 

Then we add a pseudo-user to the service, that is, users who cannot log on to the system.

# Useradd-u 700-s/sbin/nologin vmail

Before logging on to the database, we usedRootThe permission is too large and is generally limitedRootLog on to the local database.MysqlSpecifyEmailUser pairWestosAll tables in the database have all permissions.

> Grant all on westos. * to email @ '%' identified by 'email ';

Log out and log on again: UseEmailIdentity: You can see that its valid library only hasWestos.

Insert in table:

 

Write these recordsPostfixConfiguration File main. cf. Execute the following command and write it to main. cf.

[Root @ redhat ~] # Postconf-d | grep virtual

[Root @ redhat ~] # Postconf-e "virtual_mailbox_base =/home/vmail"

[Root @ redhat ~] # Postconf-e "virtual_uid_maps = static: 700"

[Root @ redhat ~] # Postconf-e "virtual_gid_maps = static: 700"

 

The basic mailbox configuration path is/Home/vmail

Virtual user used to send the emailUid = 700 gid = 700

Below we want to configureMysqlTo makePostfixWhen reading a file, it will automatically readMysql.

Template path:

/Usr/share/doc/postfixed-2.6.6/README_FILES/MYSQL_README

Cd/etc/postfix mysqlUser Configuration File

Vim users. cf

Host = localhost

User = email

Password = email

Dbname = westos

Select_field = username"Select a domain

Table = date

Where_field = username

 

To prevent writing errors, run the following command to verify the data:

 

# Postmap-q "test@test.com" mysql:/etc/postfix/users. cf

Test@test.com // If the verification is correct, the corresponding content will appear

Only users are not enough. We also send emails to domains and email addresses.

[Root @ redhat postfix] # cp-p users. cf domain. cf

[Root @ redhat postfix] # cp-p users. cf mailbox. cf

 

Vim domain. cf

 

Host = localhost

User = email

Password = email

Dbname = westos

Select_field = domain

Table = date

Where_field = domain

 

Vim mailbox. cf

 

Host = localhost

User = email

Password = email

Dbname = westos

Select_field = maildir

Table = date

Where_field = username

 

Check whether the above file is written correctly

[Root @ redhat postfix] # postmap-q "test.com" mysql:/etc/postfix/domain. cf

Test.com

[Root @ redhatpostfix] # postmap-q "test@test.com" mysql:/etc/postfix/mailbox. cf

Test.com/test/

 

Add these daysPostfixIn the main configuration file:

[Root @ redhat ~] # Postconf-e "virtual_mailbox_domains = mysql:/etc/postfix/domain. cf"

[Root @ redhat ~] # Postconf-e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox. cf"

[Root @ redhat ~] # Postconf-e "virtual_alias_maps = mysql:/etc/postfix/users. cf"

 

If yourSelinuxIs to open the following:

 

[Root @ redhat ~] # Getsebool-a | grep mysql

Allow_user_mysql_connect --> off

Mysql_connect_any --> off

[Root @ redhat ~] # Setsebool-P allow_user_mysql_connect on

 

All of the following are:

Switch/Var/lib/mysql

Rm-rf mysql. sock // This file records your previous mysql operations. I tried not to delete it and restart the service. You still cannot receive emails during the test.

RestartMysqlService

MysqlThere are two Connection Methods:

(1)TCP/IP

(2)Socket

PairMysql. sockIts role isProgram andMysqlserverIt is on the same machine and can be used to initiate a local connection.

For example, you do not need to define a connectionHostSpecificIPIf it is null orLocalhostYou can.

In this case, even if you changeMysqlExternalPortThe same is true for normal connection.

Because you areMy. iniMedium orMy. cnfAfter changing the port,Mysql. sockIsMysql serverStart the generated. After modificationMy. cnfRestart laterMysqlAnd the information has been changed.

Test:

 

[Root @ redhat vmail] # mail test@test.com

Subject: nihao

Dabendan

.

EOT

[Root @ redhat vmail] # mailq

Mail queue is empty

[Root @ redhat vmail] # ls

Test.com

 

 

 

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.