< e-Mail Service postfix+mysql>mail second article

Source: Internet
Author: User
Tags install php phpmyadmin vmail

Environment: The service is based on the first article, it is best to build a good first

The premise of playing this service is that your system is loaded with mSQL and postfix services.

Postfix+mysql mainly uses the mail service to combine with MySQL. Of course, MySQL is not very convenient to use under the command line, right, let's look at the Linux graphical use of MySQL:

The following package.

phpmyadmin-2.11.3-all-languages.tar.gz is in PHP the format combines Apache manage MySQL in the form of a Web page .

since you are using Web page to manage MySQL , of course, put the directory of this package into Apahce down there, right?

I downloaded the package directly to/var/www/html below. self-extracting

First unzip the package, the name of the package is very long, we can change the name of a short point.

# MV Phpmyadmin-2.11.3-all-languages PhpMyAdmin

Switch to this directory

Then we look at the installation steps:

[[email protected] phpmyadmin]# vim INSTALL

Phpmyadmin-installation

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

installation file Tips Let's go see this 2 a file.

Please be a look to the Documentation.txt or

documentation.html files.

we open Documentation.txt . file.

Vim Documentation.txt

Find Fast Install Quick Installs

Fourth step: 4. Now you must configure your installation. There is and methods that can is

Used. Traditionally, the users has hand-edited a copy of config.inc.php, but

Now a Wizard-style setup script was provided for those who prefer a

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

To get started and needed for some advanced features. there's a file to write about in English.

The meaning of this passage: there are 2 method: You can use the existing file to copy a config.inc.php . Or create a config.inc.php yourself, andif you create it yourself, here's what you want to write in the file:

We copy one:

# CP config.sample.inc.php config.inc.php

Then modify the reference to the fourth step, although we are copies, but only the template, the content and it prompts us to create the same.

we open config.inc.php . The file, the default red part is empty, we go to quick Install fourth copy the following code paste into this.

$cfg [' blowfish_secret '] = 'ba17c1ec07d65003'; /* Must FILL in the this for COOKIE auth! */

Apache Service has, we also need to install PHP Package:

# yum Install php php-mysql–y // installing php One is not enough and php-mysql.

Restart MySQL and the httpd Service:

then enter in the browser: the service's Ip/phpmyadmin Enter on OK up.

after that you will see the following interface, you can choose Chinese. Log in to your mysql database.

then I create a Westos Library and a Date table. The library and the table name can be casually, no need to do as I write

The structure of this table is composed 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 we landed in the database, we used Root , its permissions are too large, generally limited to Root log in to the local database and we re- MySQL Specify a Email users to Westos all the tables under the library have full permissions.

>grant all on westos.* to [email protected] '% ' identified by ' email ';

Sign out of re-login: Using Email Identity: You can see that it's a valid library and only Westos .

Insert in table:

write the few postfix the configuration file MAIN.CF. Execute the following command to write MAIN.CF

[Email protected] ~]# postconf-d | grep virtual

[Email protected] ~]# postconf-e "virtual_mailbox_base =/home/vmail"

[Email protected] ~]# postconf-e "virtual_uid_maps = static:700"

[Email protected] ~]# postconf-e "virtual_gid_maps = static:700"

the basic configuration path for a mailbox is /home/vmail

the virtual user that is used to send the message uid=700 gid=700

below we want to configure MySQL the file to make postfix when the file is read, it is automatically read MySQL the data.

Path to the template:

/usr/share/doc/postfix-2.6.6/readme_files/mysql_readme

cd/etc/postfix MySQL the User Configuration file

Vim USERS.CF

host = localhost

user = Email

Password = Email

dbname = Westos

Select_field = Username "Select a field

Table = Date

Where_field = Username

to prevent us from writing errors, you can use the command to verify:

#postmap-Q "[email protected]" MYSQL:/ETC/POSTFIX/USERS.CF

[email protected] //Verify the correct content will appear

Only the user is not enough, we send mail and domain, mailbox, etc.

[Email protected] postfix]# cp-p users.cf domain.cf

[Email protected] 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

Verify that the above file is written correctly

[email protected] postfix]# postmap-q "test.com" MYSQL:/ETC/POSTFIX/DOMAIN.CF

test.com

[ [email protected]] #postmap-Q "[email protected]" MYSQL:/ETC/POSTFIX/MAILBOX.CF

test.com/test/

add these days to the postfix in the main configuration file:

[Email protected] ~]# postconf-e "virtual_mailbox_domains = mysql:/etc/postfix/domain.cf"

[Email protected] ~]# postconf-e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

[Email protected] ~]# postconf-e "virtual_alias_maps = mysql:/etc/postfix/users.cf"

If you have SELinux is open to do the following:

[Email protected] ~]# Getsebool-a | grep MySQL

Allow_user_mysql_connect--off

Mysql_connect_any--off

[Email protected] ~]# setsebool-p allow_user_mysql_connect on

All that is done here:

Switch to /var/lib/mysql

RM-RF Mysql.sock //This file will record your previous MySQL operation, I tried not to delete it restart the service, you test the mail still can't receive

Restart MySQL Service

Mysql There are two ways to connect:

( 1 ) TCP/IP

( 2 ) Socket

the Mysql.sock , its role is Procedures and MySQLServer On the same machine, available when initiating a local connection .

For example, you don't need to define connections Host the specific IP , as long as it is empty or localhost we can.

in such cases, even if you change MySQL the external Port It is also possible to connect as normal.

because you were My.ini Medium or my.cnf after changing the port in the Mysql.sock is with every time MySQL server starts the generated. The information has been changed since you restarted MySQL when you finished changing the my.cnf .

To test:

[Email protected] vmail]# mail [email protected]

Subject:nihao

Dabendan

.

EOT

[Email protected] vmail]# MAILQ

Mail queue is empty

[[email protected] 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.