Debian + Postfix + Dovecot + squirrelmail installation configuration notes

Source: Internet
Author: User
Tags imap dovecot squirrelmail vmail
System and software installation:
1. debian4.0
2. Postfix (MTA) provides SMTP function
3. postfix-mysql provides Postfix to MySQL ing support
4. MySQL user database storage
5. Dovecot (POP3 + IMAP + SASL) provides POP3 + IMAP + (smtp sasl)
6. amavisd-New libclass-DBI-mysql-perl spamassassin ClamAV-daemon cpio ARJ zoo nomarch lzop cabextract Pax LHA unrar
Spam concerns and virus concerns
7. OpenSSL provides SSL Verification
8. phpMyAdmin libapache2-mod-php5 php5-mysql provides Web-based management of Mysql Data inventory and data.
9. squirrelmail (Mail web) provides the web mail interface to automatically install Apache

Using aptitude install or apt-Get install In Debian is easier than windows, so you can find it online.

The following describes how to create a MySQL database:

Create databases and tables
Mysqladmin password 2006 Root Password: 2006
Mysqladmin-P Create mail creates a mail database

Grant select on mail .*
To mailuser @ localhost
Identified by '20140901 ';
The password for creating a mailuser is: 2007, which only has the permission to query mail data inventory.

Create a virtual domain table: Domains
Create Table 'domains '(
Id int not null auto_increment primary key,
Name varchar (50) not null
) Engine = InnoDB;

Create a virtual user table: Users
Create Table users (
Id int (11) not null auto_increment primary key,
Domain_id int (11) not null,
User varchar (40) not null,
Password varchar (32) not null,
Constraint unique_email unique (domain_id, user ),
Foreign key (domain_id) References domains (ID) on Delete Cascade
) Engine = InnoDB;

Create a view_users table to facilitate query and further setup and verification.
Create view view_users
Select users. User as user, Concat (users. User, '@', domains. Name) as email,
Users. Password
From Users
Left join domains on users. domain_id = domains. ID;

Create a virtual alias table: aliases
Create Table aliases (
Id int (11) not null auto_increment primary key,
Domain_id int (11) not null,
Source varchar (20) not null,
Destination varchar (80) not null,
Foreign key (domain_id) References domains (ID) on Delete Cascade
) Engine = InnoDB;

Create view view_aliases
Select Concat (aliases. Source, '@', domains. Name) as email,
From aliases
Left join domains on aliases. domain_id = domains. ID;

Create a virtual domain ing file:
User = mailuser
Password = 2007
Hosts =
Dbname = Mail
Query = select 1 from domains where name = '% s'

Create a virtual mailbox ing File
User = mailuser
Password = 2007
Hosts =
Dbname = Mail
Query = select 1 from view_users where email = '% s'

Create a virtual alias ing File
User = mailuser
Password = 2007
Hosts =
Dbname = Mail
Query = select destination from view_aliases where email = '% s'

User = mailuser
Password = 2007
Hosts =
Dbname = Mail
Query = select email from view_users where email = '% s'

$> Postconf-e virtual_mailbox_domains = MYSQL:/etc/Postfix/
$> Postconf-e virtual_mailbox_maps = MYSQL:/etc/Postfix/
$> Postconf-e virtual_alias_maps = MYSQL:/etc/Postfix/, MySQL:/etc/Postfix/

$> Groupadd-G 5000 vmail
$> Useradd-G vemail-u 5000 vmail-D/home/vmail-m
$> Postconf-e virtual_uid_maps = static: 5000
$> Postconf-e virtual_gid_maps = static: 5000
To ensure the security of *. Cf files, the built-in password is used;
Chgrp Postfix/etc/Postfix/virtual-*. cf
Chmod u = RW, G = r, O =/etc/Postfix/virtual-*. cf

Configure Dovecot
To enable Postfix to send mail with Dovecot, add the following services under/etc/Postfix/master. Cf:
Dovecot Unix-N-pipe
Flags = drhu user = vmail: vmail argv =/usr/lib/Dovecot/deliver-d $ {recipient}
To enable Postfix to use Dovecot for virtual transmission, add the following items to main. Cf:
$> Postconf-e virtual_transport = Dovecot
$> Postconf-e dovecot_destination_recipient_limit = 1

Configure Dovecot. conf
/Etc/Dovecot. conf

Add the following service support
Protocols = IMAP IMAPs POP3 pop3s

Plaintext password authentication is not removed
Disable_plaintext_auth = No

Tell Dovecot that the email is placed in/home/vmail/domain/user in the form of maildir
Mail_location = maildir:/home/vmail/% d/% N

Set authentication mechanism
Machisms = plain Login

Tell Dovecot that the password is in the SQL database
Passdb SQL {
ARGs =/etc/Dovecot/dovecot-sql.conf

Similar to mail_location, when a user obtains an email, it is recorded as a log.
Userdb static {
ARGs = uid = 5000 gid = 5000 home =/home/vmail/% d/% N allow_all_users = Yes

The master part stores new emails in the user's mailbox through the user's data inventory information.
Socket listen {
Master {
Path =/var/run/Dovecot/auth-Master
Mode = 0600
User = vmail

client {
Path =/var/spool/Postfix/private/auth
mode = 0660
User = Postfix
group = Postfix
}< BR >}< br> You must customize this part: dovecot Lda is much more powerful than the built-in LDA function of Postfix. It can set quotas and email filtering,
protocol LDA {
log_path =/home/vmail/dovecot-deliver.log
auth_socket_path =/var/run/Dovecot/auth-master
postmaster_address =
mail_plugins = cmusieve
global_script_path =/home/vmail/globalsieverc

Configure dovecot-sql.conf
Driver = MySQL
Connect = host = dbname = Mail User = mailuser Password = 2007
Default_pass_scheme = Plain
Password_query = select email as user, password from view_users where user = '% U ';

Change the permission of Dovecot. conf. Set only the user in the vmail group and the root user name to read
$> Chgrp vmail/etc/Dovecot. conf
$> Chmod g + R/etc/Dovecot. conf

Configure SMTP authentication (SASL)

$> Postconf-e smtpd_sasl_type = Dovecot
$> Postconf-e smtpd_sasl_path = private/auth
$> Postconf-e smtpd_sasl_auth_enable = Yes
$> Postconf-e smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

9. Configure WebMail

Check whether Web server: apache2 has been started:
Netstat-an | grep: 80
TCP 0 0 80 * listen

In this case, you can use http: // ip/mail to access webmail.
If you want your webmail interface to be simplified Chinese, enter your email address and password, and choose Options> display preferences> language:> Chinese Simple.
If you want to set the webmail interface to simplified Chinese by default, run/etc/squirrelmail/CONF. pl and enter 10. You can see the following interface:
Squirrelmail configuration: Read: config. php (1.4.0)
Language preferences
1. default language: en_us
2. Default charset: iso-8859-1
3. Enable lossy encoding: false

Set to similar:
Squirrelmail configuration: Read: config. php (1.4.0)
Language preferences
1. default language: zh_cn
2. Default charset: gb2312
3. Enable lossy encoding: false

Restart the Web Service:
/Etc/init. d/apache2 restart
Forcing reload of Web Server: apache2.

Use http: // ip/mail to access web mail. You can find that the default language of squirrelmail has changed to simplified Chinese.

Note: squirrelmail supports many extension functions such as password modification, automatic reply, and incoming call reminder. Download the corresponding plug-in installation package from the squirrelmail website. Http://

Please give me more advice on any mistakes!

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: 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.