Installation of a POSTFIX email system of Medium and Small Scale
Source: Internet
Author: User
Installation of a small-and medium-sized POSTFIX email system-Linux Enterprise Application-Linux server application information. The following is a detailed description. The entire installation process is based on the FreeBSD 4.7 environment. All functions are installed on one server and have the mail.localhost.com domain name.
1. Install webmin
Download webmin-1.070.tar.gz
# Tar zxvf webmin-1.070.tar.gz
# Cd webmin-1.070
#./Setup. sh
After installation, you can manage the mysql database, such as adding users and adding data to the table.
2. Database settings
2.1 install the mysql database
This system uses the mysql database installed by ports in FreeBSD 4.7 (An error occurred while installing postfix when the original code was used at that time, so this problem was solved by installing ports ).
# Cd/usr/ports/databases/mysql323-server/
# Make install
# Cd work/mysql-3.23.52/
# Scripts/mysql_install_db
# Cp support-files/my-medium.cnf/etc/my. cnf
# Echo "/usr/local/bin/safe_mysqld -- user = mysql &">/etc/rc. local
#/Usr/local/bin/safe_mysqld -- user = mysql & start the mysql Service
2.2 set the database
2.2.1 Add a mysql user:
1. Use webmin-> mysql database server-> User Permissions, add the user postfix, password postfix, and host localhost, and set the corresponding permissions.
2. Use SQL statements to add users:
# Cd/usr/local/bin
#./Mysql? D mysql? P
Password:
Mysql> insert into user (host, user, password)
-> VALUES ('localhost', 'postfix ','');
Query OK. I row affected (0.00 sec)
Mysql> UPDATA user SET password = password ('postfix ')
-> WHERE user = 'postfix ';
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK. 0 rows affected( 0.01 sec)
Mysql> GRANT select, insert, update on mail. * TO postfix
Query OK. 0 rows affected( 0.01 sec)
Mysql> exit
2.2.2. Add a table to the database
# Cd/usr/local/bin/
# Ee postfix. SQL
Create database;
Grant all on mail. * mail @ localhost identified by "postfix ";
Flush privileges;
Use mail;
Create table forward (
Username varchar (255) not null default '', // local address
Forward_addr varchar (255) default NULL, // forwarding address
Primary key (username)
) TYPE = MyISAM;
Create table transport (
Domain varchar (255) not null default '', // mail domain
Transport varchar(icon_cool.gif default NULL, // Processing Method
Primary key (domain)
) TYPE = MyISAM;
Create table users (
Username varchar (128) not null default '', // User Name
Domain varchar (128) not null default '', // mail domain
Address varchar (128) not null default '', // email address
Password varchar (128) not null default '', // User password (plaintext)
Uid int (6) not null default '123', // uid
Gid int (6) not null default '20140901', // gid
Home varchar (255) not null default '/', // home directory
Maildir varchar (255) not null default '', // maildir directory
Quota varchar (255) not null default '', // mailbox capacity
Mailok tinyint (3) not null default '1 ',
Bool1 tinyint (3) not null default '1 ',
Bool2 tinyint (3) not null default '1 ',
Primary key (address ),
Unique key address (address ),
KEY address_2 (address)
) TYPE = MyISAM;
Save and exit.
#./Mysql? U postfix? P <postfix. SQL
# Password: postfix
2.2.3 add data to a table
#/Usr/local/bin
#./Mysql? U postfix? P
Password :******
Mysql> use mail
Mysql> insert into transport (domain, transport)
-> VALUES ('localhost. com', 'virtual :');
Mysql> insert into users (username, domain, address, password, uid, gid,
Home, maildir, quota, mailok, bool1, bool2)
-> VALUES ('test', 'localhost. com', 'test .localhost.com ',
'Test', '000000', '000000 ','/',
'/Var/postfix_mail/test/Maildir/', '000000', '1', '1', '1 ');
Mysql> exit
3. Install CYRUS-SASL
# Tar? Zxvf cyrus-sasl-1.5.27
# Cd cyrus-sasl-1.5.27
#./Configure -- with-pwcheck =/var/pwcheck -- enable-login
-- Enable-plain
# Make
# Make install
Create the smtpd. conf file under/usr/local/lib/sasl and add the following content:
Pwcheck_method: mysql
Mysql_user: postfix
Mysql_passwd: postfix
Mysql_host: localhost
Mysql_database: mail
Mysql_table: users
Mysql_uidcol: address
Mysql_pwdcol: password
4. Install and set postfix
4.1 install postfix
4.4.1 compile/etc/rc. conf and set sendmail_enable = "NO"
# Mv/usr/bin/newaliases. OFF
# Mv/usr/bin/mailq. OFF
# Mv/usr/sbin/sendmail. OFF
# Pw groupadd postfix? G 1024
# Pw groupadd postdrop? G 1025
# Pw useradd postfix? U 1024? G postfix
# Echo 'postfix: root'>/etc/aliases
4.4.2 install postfix and corresponding quota patch
# Tar zxvf postfix-1.1.11.tar.gz
# Patch <postfix-1.1.11_quota_maildirsize.patch
# Make? F Makefile. init makefiles 'ccargs =-DUSE_SASL_AUTH? DHAS_MYSQL? I/usr/include/mysql ''auxlibs =-L/usr/lib/mysql? Lmysqlclient? Lasal? Lz? Lm'
# Make
# Make install follow the default path and press enter to install the successful postfix. If an error occurs, enter:/tmp when "tempdir" is prompted, so that you can generally pass.
4.2 set postfix
By default, postfix is installed in the/etc/postfix directory.
# Cd/etc/postfix
4.2.1 compile the main configuration file main. cf
# Add the following content to ee main. cf:
# Base configure
Myhostname = mail.localhost.com // machine name of the Local Machine
Mydomain = local.com // Domain Name
Mynetworks = 127.0.0.0/8 192.168.0.0/16 // ip address segment that can be sent without smtp authentication
Home_mailbox = Maildir // The email format used is Maildir/
Smtpd_banner = Welcome to localhost.com mail system! // Smtp welcome information
# Mysql configure
Transport_maps = mysql:/etc/postfix/transport. cf // emails in the specified domain can be received by postfix
Virtual_mailbox_base = // specify the root directory of the user's mailbox
Virtual_uid_maps = mysql:/etc/postfix/ids. cf // specify the postfix account ID
Virtual_gid_maps = mysql:/etc/postfix/gds. cf // specify the ID of the postfix Group
Virtual_mailbox_maps = mysql:/etc/postfix/users. cf // specifies the user's email directory.
Virtual_maps = mysql:/etc/postfix/forward. cf // specifies the setting of Automatic Mail forwarding.
# Quota configure
Message_size_limit = 5000000 // size limit of a single email
Virtual_mailbox_limit = 5000000 // default mailbox size
Virtual_mailbox_limit_maps = mysql:/etc/postfix/quota. cf // The mailbox size of each user
Virtual_mailbox_limit_override = yes // whether to overwrite the default mailbox size
Inet_interfaces = all // listen to all ports
Inet_interfaces = 192.168.80.21 // an external user can also send an email.
4.2.2 view the master. cf file must contain the following line
Virtual unix-n--virtual
4.2.3 compile transport. cf
# Touch transport. cf
# Add the following content to ee transport. cf:
User = postfix
Password = postfix
Dbname = mail
Table = transport
Select_field = transport
Where_field = domain
Hosts = localhost
# Touch gds. cf
# Ee gds. cf
User = postfix
Password = postfix
Dbname = mail
Table = users
Select_field = gid
Where_field = address
Hosts = localhost
4.2.6. Compile forward. cf
# Touch forward. cf
# Ee forward. cf
User = postfix
Password = postfix
Dbname = mail
Table = forward
Select_field = forward_addr
Where_field = username
Hosts = localhost
4.2.7. Compile users. cf
# Touch users. cf
# Ee users. cf
User = postfix
Password = postfix
Dbname = mail
Table = users
Select_field = maildir
Where_field = address
Hosts = localhost
4.2.8. Compile quota. cf
# Touch quota. cf
# Ee quota. cf
User = postfix
Password = postfix
Dbname = mail
Table = users
Select_field = quota
Where_field = address
Hosts = localhost
4.3 start postfix
#/Usr/sbin/postfix start
Postfix/postfix-script: starting the Postfix mail system
# Echo "/usr/sbin/postfix start">/etc/rc. local
# Telnet localhost 25
Connected to localhost.localhost.com.
Escape character is '^]'.
220 Welcome to localhost mail system!
4.4 Test postfix
4.4.1 create a mail storage directory
# Cd/var
# Mkdir postfix_mail
# Chown? R postfix: postfix/var/postfix_mail
4.4.2 use the client to send an email
In this case, you can use foxmail or outlook on the client to send an email to test.localhost.com, and then view the email under/var/postfix/test/Maildir/. If you receive the email, it means that SMTP is working properly, if you have any questions, carefully check your own steps.
5. Install and set courier-imap
5.1 install courier-imap
# Cd/usr/ports/mail/courier-imap
# Make
# Cd work/courier-imap-1.5.3
#./Configure? With-db = db? Without-socks? Disable-root-check
# Make
# Make install
#/Usr/lib/courier-imap/libexec/authlib/authdaemon start
# Echo "/usr/lib/courier-imap/libexec/authlib/authdaemon start">/etc/rc. local
5.2 Add a user
# Cd/usr/local/bin
#./Mysql? D mysql? P
Password :*******
Mysql> insert into user (host, user, password)
-> VALUES ('localhost', 'courier ','');
Mysql> UPDATA user SET password = password ('hahaha ')
-> WHERE user = 'courier ';
Mysql> flush privileges;
Mysql> GRAN select, insert, update on mail. * TO courier;
Mysql> exit
# Telnet to localhost 110
Trying 127.0.0.1...
Connected to localhost.cw-isquare.com.
Escape character is '^]'.
+ OK Hello there
# Quit
# Telnet to localhost 143
* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc. See COPYING for distribution information.
# Quit
5. Install and set sqwebmail
5.1、install sqwebmail-3.5.0-cn.tar.gz
# Tar zxvf sqwebmail-3.5.0.tar.gz
# Cd sqwebmail-3.5.0
#./Configure -- without-authpam? With-db = db -- enable-webpass = no -- without-authpwd -- without-authshadow
# Make configure-check
# Make
# Make install-strip
# Make install-configure
#/Usr/local/share/sqwebmail/libexec/authlib/authdaemond start
# Echo "/usr/local/share/sqwebmail/libexec/authlib/authdaemond start">/etc/rc. local
5.2 configure sqwebmail-3.5.0
5.2.1 install apache
# Tar apache_1.3.22.tar.gz
# Cd apache_1.3.22
#./Configure? Prefix =/usr/local/apache
# Make
# Make install
5.2.2. Set sqwebmail
# Cd/usr/local/share/sqwebmail
# Ee authdaemonrc
Authmodulelist = "authmysql authpam"
Authmodulelistorig = "authcustom authcram authuserdb authmysql authpam"
Daemons = 5
Version = "authdaemond. mysql"
Authdaemonvar = "/usr/local/share/sqwebmail/var/authdaemon"
Enter in the address bar of the client browser
Http://mail.localhost.com/cgi-bin/sqwebmail
Enter the user name and password to log in and send and receive emails.
Note: You must enter the full name for the user name, that is, enter the domain name together.
5.2.4 set apache page Jump
# Cd/usr/local/apache/htdocs
# Touch index.html
# Ee index.html
. Com/cgi-bin/sqwebmail? Index = 1 ">
Now you can enter the following in the address bar of IE:
Http://mail.localhost.com
To access sqwebmail.
This article has not been added to smtp authentication. A friend told me in the post last time that the authentication method was used. Because there is no time, I did not try it. If there is no problem with the mail list, I cannot find a solution. If a friend sees this article, please add the smtp authentication and Mail List functions. This is complete. Here, I would like to express my gratitude ~
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