First
Config DNS Server using bind package
resolv.conf
SELinux
sudo gedit /etc/selinux/config
sudo gedit /etc/selinux/config
SELINUX=disable
SeLinux;
SELINUX=enforcing
SeLinux
CentOS:
sudo yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
iptables:
sudo gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1024 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1025 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4190 -j ACCEPT
sudo service iptables restart
sudo yum -y install telnet
sudo yum -y install postfix* dovecot*
sudo yum -y install httpd mysql mysql-server mysql-devel php php-mysql
sudo yum -y install php-mbstring php-imap php-xml
sudo yum install pam-devel
sudo yum -y install telnet postfix* dovecot* httpd mysql mysql-server mysql-devel php php-mysql php-mbstring php-imap php-xml pam-devel
sudo chkconfig postfix on
sudo chkconfig dovecot on
sudo chkconfig httpd on
sudo chkconfig mysqld on
sudo gedit /etc/httpd/conf/httpd.conf //#ServerName www.example.com:80
sudo service postfix restart
sudo service dovecot restart
sudo service httpd restart
sudo service mysqld restart
vmail
sudo useradd -u 2000 -d /var/vmail -m -s /sbin/nologin vmail
mail:
mysqladmin -uroot password 'root'
mysql -h localhost -uroot -p
mysql> GRANT ALL PRIVILEGES ON mail.* TO root@localhost IDENTIFIED BY 'root';
mysql> create database mail;
mysql> GRANT ALL PRIVILEGES ON mail.* TO admin@"localhost" IDENTIFIED BY '123123' WITH GRANT OPTION;
mysql> flush privileges;
postfixadmin:
http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-2.3.6/postfixadmin-2.3.6.tar.gz/download
postfixadmin,/var/www/html
sudo cp -rf /home/pandy/ /postfixadmin /var/www/html
postfixadmin:
sudo gedit /var/www/html/postfixadmin/config.inc.php
------------
$CONF['configured'] = true;
$CONF['default_language'] = 'cn';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'admin';
$CONF['database_password'] = '123123';
$CONF['database_name'] = 'mail';
$CONF['admin_email'] = 'admin@pandy8.com';
$CONF['encrypt'] = 'dovecot:CRAM-MD5';
$CONF['dovecotpw'] = "/usr/bin/doveadm pw";
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['aliases'] = '1000';
$CONF['mailboxes'] = '1000';
$CONF['maxquota'] = '1000';
$CONF['fetchmail'] = 'NO';
$CONF['emailcheck_resolve_domain']='NO';
$CONF['quota'] = 'YES';
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';
postfixadmin:
http://127.0.0.1/postfixadmin/setup.php
:admin / admin, generate password hash,hash code,
code,:sudo gedit /var/www/html/postfixadmin/config.inc.php
$CONF['setup_password'] = 'ae3e1cb27c62fae6c43dc1fd84853207:03bf21e651640880b910317a27fdb205fe8949fa'; //
postfixadmin
=================================
postfxiadmin
/usr/local/bin/maildir-creation.sh ,:
sudo gedit /usr/local/bin/maildir-creation.sh
--------------------------------------------
#!/bin/bash
HOME_DIR="/var/vmail"
USER_NAME="vmail"
GROUP_NAME="vmail"
if [ ! -d ${HOME_DIR}/$1 ] ; then
mkdir ${HOME_DIR}/$1
chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1
fi
mkdir ${HOME_DIR}/$1/$2
chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1/$2
/usr/local/bin/maildir-deletion.sh ,:
sudo gedit /usr/local/bin/maildir-deletion.sh
----------------------------------------------
#!/bin/bash
#
# vmta ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
#
if [ $# -ne 2 ] ; then
exit 127
fi
DOMAIN="$1"
USER="$2"
HOME_DIR="/var/vmail"
USER_DIR="${HOME_DIR}/${DOMAIN}/${USER}"
TRASH_DIR="${HOME_DIR}/deleted-maildirs"
DATE=`date "+%Y%m%d_%H%M%S"`
if [ ! -d "${TRASH_DIR}/${DOMAIN}" ] ; then
mkdir -p "${TRASH_DIR}/${DOMAIN}"
fi
if [ -d "${USER_DIR}" ] ; then
mv ${USER_DIR} ${TRASH_DIR}/${DOMAIN}/${USER}-${DATE}
fi
sudo mkdir /var/vmail/deleted-maildirs
sudo chown -R vmail.vmail /var/vmail/deleted-maildirs/
sudo chmod 750 /usr/local/bin/maildir-*
sudo chown vmail.vmail /usr/local/bin/maildir-*
sudo
/etc/sudoers
sudo vim /etc/sudoers
----------------------------
vmail ALL = NOPASSWD: /usr/local/bin/maildir-creation.sh
vmail ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
#Defaults requiretty
esc , :wq!,
postfixadmin
create-mailbox.php ,229:
sudo gedit /var/www/html/postfixadmin/create-mailbox.php
db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");
system("sudo /usr/local/bin/maildir-creation.sh $fDomain ".$_POST['fUsername']);
delete.php ,146:
sudo gedit /var/www/html/postfixadmin/delete.php
db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete);
:
$userarray=explode("@",$fDelete);
$user=$userarray[0];
$domain=$userarray[1];
system("sudo /usr/local/bin/maildir-deletion.sh $domain $user");
4、Postfix
http://www.centospub.com/make/postfix_smtp.html
=========================================
/etc/postfix/main.cf:
sudo gedit /etc/postfix/main.cf
---------------------------------------
myhostname = bogon //hostname
mydomain = pandy8.com
myorigin = $mydomain
inet_interfaces = all
mydestination = localhost //MX
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //unknown user
mynetworks_style = host
--------------------------------------#=======================================================================
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
# See: http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu8.04-p2
# The follwing lines connect Postfix with the MySQL database that contains information about
# the virtual users/accounts hosted. See proxymap(8) virtual(5) and mysql_table(5)
#
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
#
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
#
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
#
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, this user has exceeded their disk space quota, please try again later.
virtual_overquota_bounce = yes
#
#Specify the user/group that owns the mail folders. I'm not sure if this is strictly necessary when using Dovecot's LDA.
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000
#
#Specifies which tables proxymap can read: http://www.postfix.org/postconf.5.html#proxy_read_maps
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
SMTP
---------------------------------------
#=======================================================================
#SASL SUPPORT FOR CLIENTS
#
# The following options set parameters needed by Postfix to enable
# SMTP AUTH support using Dovecot's SASL component for authentication of mail clients.
# See: /usr/share/doc/postfix-2.3.3/README_FILES/SASL_README - http://www.postfix.org/SASL_README.html
# And /usr/share/doc/dovecot-1.0.7/wiki/HowTo.PostfixAndDovecotSASL.txt - http://wiki.dovecot.org/HowTo/PostfixAndDovecotSASL
#
# Turns on sasl authorization
smtpd_sasl_auth_enable = yes
#
#Use dovecot for authentication
smtpd_sasl_type = dovecot
#
# Path to UNIX socket for SASL
smtpd_sasl_path = /var/run/dovecot/auth-client
#
#Disable anonymous login. We don't want to run an open relay for spammers.
smtpd_sasl_security_options = noanonymous
#
#Adds support for email software that doesn't follow RFC 4954.
#This includes most versions of Microsoft Outlook before 2007.
broken_sasl_auth_clients = yes
#
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
Dovecot
---------------------------------------
#=======================================================================
# TRANSPORT MAP
#
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
master.cf
sudo gedit /etc/postfix/master.cf
---------------------------------------
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}
Mysql
==================================
sudo gedit /etc/postfix/mysql_virtual_domains_maps.cf
---------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
#optional query to use when relaying for backup MX
#query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_alias_maps.cf
----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_mailbox_maps.cf
-----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
--------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'
5、Dovecot
================================================
sudo gedit /etc/dovecot/dovecot.conf
---------------------------------
protocols = imap pop3
listen = *
dict {
quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
!include conf.d/*.conf
sudo gedit /etc/dovecot/conf.d/10-auth.conf
---------------------------------
disable_plaintext_auth = no
auth_mechanisms = plain login cram-md5
!include auth-sql.conf.ext
sudo gedit /etc/dovecot/conf.d/10-mail.conf
--------------------------------
mail_location = maildir:%hMaildir
mbox_write_locks = fcntl
sudo gedit /etc/dovecot/conf.d/10-master.conf
---------------------------
service imap-login {
inet_listener imap {
}
inet_listener imaps {
}
}
service pop3-login {
inet_listener pop3 {
}
inet_listener pop3s {
}
}
service lmtp {
unix_listener lmtp {
}
}
service imap {
}
service pop3 {
}
service auth {
unix_listener auth-userdb {
mode = 0600
user = vmail
group = vmail
}
unix_listener auth-client {
mode = 0600
user = postfix
group = postfix
}
}
service auth-worker {
}
service dict {
unix_listener dict {
mode = 0600
user = vmail
group = vmail
}
}
sudo gedit /etc/dovecot/conf.d/15-lda.conf
---------------------
protocol lda {
mail_plugins = quota
postmaster_address = admin@pandy8.com
}
sudo gedit /etc/dovecot/conf.d/20-imap.conf
-----------------------------
protocol imap {
mail_plugins = quota imap_quota
}
sudo gedit /etc/dovecot/conf.d/20-pop3.conf
------------------------------
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
mail_plugins = quota
}
sudo gedit /etc/dovecot/conf.d/90-quota.conf
----------------------------
plugin {
quota_rule = *:storage=1G
}
plugin {
}
plugin {
quota = dict:User quota::proxy::quota
}
plugin {
}
sudo gedit /etc/dovecot/dovecot-sql.conf.ext
--------------------------
driver = mysql
connect = host=localhost dbname=mail user=admin password=123123
default_pass_scheme = CRAM-MD5
user_query = SELECT CONCAT('/var/vmail/', maildir) AS home, 2000 AS uid, 2000 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE username = '%u' AND active='1'
password_query = SELECT username AS user, password, CONCAT('/var/vmail/', maildir) AS userdb_home, 2000 AS userdb_uid, 2000 AS userdb_gid, CONCAT('*:bytes=', quota) as userdb_quota_rule FROM mailbox WHERE username = '%u' AND active='1'
sudo gedit /etc/dovecot/dovecot-dict-sql.conf.ext
-----------------------------
connect = host=localhost dbname=mail user=admin password=123123
map {
pattern = priv/quota/storage
table = quota2
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota2
username_field = username
value_field = messages
}
sudo gedit /etc/pam.d/dovecot
-------------------------
#%PAM-1.0
#auth required pam_nologin.so
#auth include password-auth
#account include password-auth
#session include password-auth
auth required pam_unix.so nullok
account required pam_unix.so
CentOS:reboot
:
netstat -tlunp | grep ':25'
netstat -tlunp | grep ':110'
sudo postfix check //,
sudo tail 0f /var/log/maillog //maillog
:http://127.0.0.1/postfixadmin/setup.php
:admin, admin@pandy8.com, admin, admin
!,(admin@pandy8.com), ;
:http://127.0.0.1/postfixadmin/login.php
:admin@pandy8.com/admin,
:pandy8.com;
:test@pandy8.com
:
[pandy@localhost ~]$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 bogon ESMTP Postfix
ehlo test@pandy8.com<---
250-bogon
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN CRAM-MD5
250-AUTH=PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
[pandy@bogon ~]$ telnet localhost 110
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user test@pandy8.com<---
+OK
pass test<--
+OK Logged in.
quit<---
+OK Logging out.
Connection closed by foreign host.
roundcubemail
===================================
http://superb-dca2.dl.sourceforge.net/project/roundcubemail/roundcubemail/0.9.1/roundcubemail-0.9.1.tar.gz
:roundcubemail,html
sudo cp -rf /home/pandy/ /roundcubemail /var/www/html/
roundcubemail
mysql -h localhost -uroot -p
mysql> CREATE DATABASE roundcubemail;
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'pa5swd';
mysql> flush privileges;
mysql
CentOS:
sudo yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
iptables:
sudo gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1024 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1025 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4190 -j ACCEPT
sudo service iptables restart
sudo yum -y install telnet
sudo yum -y install postfix* dovecot*
sudo yum -y install httpd mysql mysql-server mysql-devel php php-mysql
sudo yum -y install php-mbstring php-imap php-xml
sudo yum install pam-devel
sudo yum -y install telnet postfix* dovecot* httpd mysql mysql-server mysql-devel php php-mysql php-mbstring php-imap php-xml pam-devel
sudo chkconfig postfix on
sudo chkconfig dovecot on
sudo chkconfig httpd on
sudo chkconfig mysqld on
sudo gedit /etc/httpd/conf/httpd.conf //#ServerName www.example.com:80
sudo service postfix restart
sudo service dovecot restart
sudo service httpd restart
sudo service mysqld restart
vmail
sudo useradd -u 2000 -d /var/vmail -m -s /sbin/nologin vmail
mail:
mysqladmin -uroot password 'root'
mysql -h localhost -uroot -p
mysql> GRANT ALL PRIVILEGES ON mail.* TO root@localhost IDENTIFIED BY 'root';
mysql> create database mail;
mysql> GRANT ALL PRIVILEGES ON mail.* TO admin@"localhost" IDENTIFIED BY '123123' WITH GRANT OPTION;
mysql> flush privileges;
postfixadmin:
http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-2.3.6/postfixadmin-2.3.6.tar.gz/download
postfixadmin,/var/www/html
sudo cp -rf /home/pandy/ /postfixadmin /var/www/html
postfixadmin:
sudo gedit /var/www/html/postfixadmin/config.inc.php
------------
$CONF['configured'] = true;
$CONF['default_language'] = 'cn';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'admin';
$CONF['database_password'] = '123123';
$CONF['database_name'] = 'mail';
$CONF['admin_email'] = 'admin@pandy8.com';
$CONF['encrypt'] = 'dovecot:CRAM-MD5';
$CONF['dovecotpw'] = "/usr/bin/doveadm pw";
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['aliases'] = '1000';
$CONF['mailboxes'] = '1000';
$CONF['maxquota'] = '1000';
$CONF['fetchmail'] = 'NO';
$CONF['emailcheck_resolve_domain']='NO';
$CONF['quota'] = 'YES';
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';
postfixadmin:
http://127.0.0.1/postfixadmin/setup.php
:admin / admin, generate password hash,hash code,
code,:sudo gedit /var/www/html/postfixadmin/config.inc.php
$CONF['setup_password'] = 'ae3e1cb27c62fae6c43dc1fd84853207:03bf21e651640880b910317a27fdb205fe8949fa'; //
postfixadmin
=================================
postfxiadmin
/usr/local/bin/maildir-creation.sh ,:
sudo gedit /usr/local/bin/maildir-creation.sh
--------------------------------------------
#!/bin/bash
HOME_DIR="/var/vmail"
USER_NAME="vmail"
GROUP_NAME="vmail"
if [ ! -d ${HOME_DIR}/$1 ] ; then
mkdir ${HOME_DIR}/$1
chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1
fi
mkdir ${HOME_DIR}/$1/$2
chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1/$2
/usr/local/bin/maildir-deletion.sh ,:
sudo gedit /usr/local/bin/maildir-deletion.sh
----------------------------------------------
#!/bin/bash
#
# vmta ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
#
if [ $# -ne 2 ] ; then
exit 127
fi
DOMAIN="$1"
USER="$2"
HOME_DIR="/var/vmail"
USER_DIR="${HOME_DIR}/${DOMAIN}/${USER}"
TRASH_DIR="${HOME_DIR}/deleted-maildirs"
DATE=`date "+%Y%m%d_%H%M%S"`
if [ ! -d "${TRASH_DIR}/${DOMAIN}" ] ; then
mkdir -p "${TRASH_DIR}/${DOMAIN}"
fi
if [ -d "${USER_DIR}" ] ; then
mv ${USER_DIR} ${TRASH_DIR}/${DOMAIN}/${USER}-${DATE}
fi
sudo mkdir /var/vmail/deleted-maildirs
sudo chown -R vmail.vmail /var/vmail/deleted-maildirs/
sudo chmod 750 /usr/local/bin/maildir-*
sudo chown vmail.vmail /usr/local/bin/maildir-*
sudo
/etc/sudoers
sudo vim /etc/sudoers
----------------------------
vmail ALL = NOPASSWD: /usr/local/bin/maildir-creation.sh
vmail ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
#Defaults requiretty
esc , :wq!,
postfixadmin
create-mailbox.php ,229:
sudo gedit /var/www/html/postfixadmin/create-mailbox.php
db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");
system("sudo /usr/local/bin/maildir-creation.sh $fDomain ".$_POST['fUsername']);
delete.php ,146:
sudo gedit /var/www/html/postfixadmin/delete.php
db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete);
:
$userarray=explode("@",$fDelete);
$user=$userarray[0];
$domain=$userarray[1];
system("sudo /usr/local/bin/maildir-deletion.sh $domain $user");
4、Postfix
http://www.centospub.com/make/postfix_smtp.html
=========================================
/etc/postfix/main.cf:
sudo gedit /etc/postfix/main.cf
---------------------------------------
myhostname = bogon //hostname
mydomain = pandy8.com
myorigin = $mydomain
inet_interfaces = all
mydestination = localhost //MX
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //unknown user
mynetworks_style = host
--------------------------------------#=======================================================================
# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.
# See: http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu8.04-p2
# The follwing lines connect Postfix with the MySQL database that contains information about
# the virtual users/accounts hosted. See proxymap(8) virtual(5) and mysql_table(5)
#
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
#
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
#
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
#
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, this user has exceeded their disk space quota, please try again later.
virtual_overquota_bounce = yes
#
#Specify the user/group that owns the mail folders. I'm not sure if this is strictly necessary when using Dovecot's LDA.
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000
#
#Specifies which tables proxymap can read: http://www.postfix.org/postconf.5.html#proxy_read_maps
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
SMTP
---------------------------------------
#=======================================================================
#SASL SUPPORT FOR CLIENTS
#
# The following options set parameters needed by Postfix to enable
# SMTP AUTH support using Dovecot's SASL component for authentication of mail clients.
# See: /usr/share/doc/postfix-2.3.3/README_FILES/SASL_README - http://www.postfix.org/SASL_README.html
# And /usr/share/doc/dovecot-1.0.7/wiki/HowTo.PostfixAndDovecotSASL.txt - http://wiki.dovecot.org/HowTo/PostfixAndDovecotSASL
#
# Turns on sasl authorization
smtpd_sasl_auth_enable = yes
#
#Use dovecot for authentication
smtpd_sasl_type = dovecot
#
# Path to UNIX socket for SASL
smtpd_sasl_path = /var/run/dovecot/auth-client
#
#Disable anonymous login. We don't want to run an open relay for spammers.
smtpd_sasl_security_options = noanonymous
#
#Adds support for email software that doesn't follow RFC 4954.
#This includes most versions of Microsoft Outlook before 2007.
broken_sasl_auth_clients = yes
#
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
Dovecot
---------------------------------------
#=======================================================================
# TRANSPORT MAP
#
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
master.cf
sudo gedit /etc/postfix/master.cf
---------------------------------------
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}
Mysql
==================================
sudo gedit /etc/postfix/mysql_virtual_domains_maps.cf
---------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
#optional query to use when relaying for backup MX
#query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_alias_maps.cf
----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_mailbox_maps.cf
-----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'
sudo gedit /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
--------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'
5、Dovecot
================================================
sudo gedit /etc/dovecot/dovecot.conf
---------------------------------
protocols = imap pop3
listen = *
dict {
quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
!include conf.d/*.conf
sudo gedit /etc/dovecot/conf.d/10-auth.conf
---------------------------------
disable_plaintext_auth = no
auth_mechanisms = plain login cram-md5
!include auth-sql.conf.ext
sudo gedit /etc/dovecot/conf.d/10-mail.conf
--------------------------------
mail_location = maildir:%hMaildir
mbox_write_locks = fcntl
sudo gedit /etc/dovecot/conf.d/10-master.conf
---------------------------
service imap-login {
inet_listener imap {
}
inet_listener imaps {
}
}
service pop3-login {
inet_listener pop3 {
}
inet_listener pop3s {
}
}
service lmtp {
unix_listener lmtp {
}
}
service imap {
}
service pop3 {
}
service auth {
unix_listener auth-userdb {
mode = 0600
user = vmail
group = vmail
}
unix_listener auth-client {
mode = 0600
user = postfix
group = postfix
}
}
service auth-worker {
}
service dict {
unix_listener dict {
mode = 0600
user = vmail
group = vmail
}
}
sudo gedit /etc/dovecot/conf.d/15-lda.conf
---------------------
protocol lda {
mail_plugins = quota
postmaster_address = admin@pandy8.com
}
sudo gedit /etc/dovecot/conf.d/20-imap.conf
-----------------------------
protocol imap {
mail_plugins = quota imap_quota
}
sudo gedit /etc/dovecot/conf.d/20-pop3.conf
------------------------------
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
mail_plugins = quota
}
sudo gedit /etc/dovecot/conf.d/90-quota.conf
----------------------------
plugin {
quota_rule = *:storage=1G
}
plugin {
}
plugin {
quota = dict:User quota::proxy::quota
}
plugin {
}
sudo gedit /etc/dovecot/dovecot-sql.conf.ext
--------------------------
driver = mysql
connect = host=localhost dbname=mail user=admin password=123123
default_pass_scheme = CRAM-MD5
user_query = SELECT CONCAT('/var/vmail/', maildir) AS home, 2000 AS uid, 2000 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE username = '%u' AND active='1'
password_query = SELECT username AS user, password, CONCAT('/var/vmail/', maildir) AS userdb_home, 2000 AS userdb_uid, 2000 AS userdb_gid, CONCAT('*:bytes=', quota) as userdb_quota_rule FROM mailbox WHERE username = '%u' AND active='1'
sudo gedit /etc/dovecot/dovecot-dict-sql.conf.ext
-----------------------------
connect = host=localhost dbname=mail user=admin password=123123
map {
pattern = priv/quota/storage
table = quota2
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota2
username_field = username
value_field = messages
}
sudo gedit /etc/pam.d/dovecot
-------------------------
#%PAM-1.0
#auth required pam_nologin.so
#auth include password-auth
#account include password-auth
#session include password-auth
auth required pam_unix.so nullok
account required pam_unix.so
CentOS:reboot
:
netstat -tlunp | grep ':25'
netstat -tlunp | grep ':110'
sudo postfix check //,
sudo tail 0f /var/log/maillog //maillog
:http://127.0.0.1/postfixadmin/setup.php
:admin, admin@pandy8.com, admin, admin
!,(admin@pandy8.com), ;
:http://127.0.0.1/postfixadmin/login.php
:admin@pandy8.com/admin,
:pandy8.com;
:test@pandy8.com
:
[pandy@localhost ~]$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 bogon ESMTP Postfix
ehlo test@pandy8.com<---
250-bogon
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN CRAM-MD5
250-AUTH=PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
[pandy@bogon ~]$ telnet localhost 110
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user test@pandy8.com<---
+OK
pass test<--
+OK Logged in.
quit<---
+OK Logging out.
Connection closed by foreign host.
roundcubemail
===================================
http://superb-dca2.dl.sourceforge.net/project/roundcubemail/roundcubemail/0.9.1/roundcubemail-0.9.1.tar.gz
:roundcubemail,html
sudo cp -rf /home/pandy/ /roundcubemail /var/www/html/
roundcubemail
mysql -h localhost -uroot -p
mysql> CREATE DATABASE roundcubemail;
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'pa5swd';
mysql> flush privileges;
mysql
:http://dev.mysql.com/downloads/tools/workbench/
:http://download.softagency.net/MySQL/Downloads/MySQLGUITools/
:roundcubemail/SQL/mysql.initial.sql
roundcubemail
Roundcubemail
cd /var/www/html/roundcubemail/config/
sudo cp db.inc.php.dist db.inc.php
sudo gedit db.inc.php
:
$rcmail_config['db_dsnw'] = 'mysql://roundcubemail:pa5swd@localhost/roundcubemail';
sudo cp main.inc.php.dist main.inc.php
sudo gedit main.inc.php
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['username_domain'] = 'pandy8.com';
$rcmail_config['mail_domain'] = 'mail.pandy8.com';
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['product_name'] = 'RH Webmail';
httpd:
sudo service httpd restart;
:http://127.0.0.1/roundcubemail/
:test@pandy8.com/test
postfixadmin
Roundcube:http://trac.roundcube.net/wiki/Plugin_Repository
:http://download.softagency.net/MySQL/Downloads/MySQLGUITools/
:roundcubemail/SQL/mysql.initial.sql
roundcubemail
Roundcubemail
cd /var/www/html/roundcubemail/config/
sudo cp db.inc.php.dist db.inc.php
sudo gedit db.inc.php
:
$rcmail_config['db_dsnw'] = 'mysql://roundcubemail:pa5swd@localhost/roundcubemail';
sudo cp main.inc.php.dist main.inc.php
sudo gedit main.inc.php
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['username_domain'] = 'pandy8.com';
$rcmail_config['mail_domain'] = 'mail.pandy8.com';
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['product_name'] = 'RH Webmail';
httpd:
sudo service httpd restart;
:http://127.0.0.1/roundcubemail/
:test@pandy8.com/test
postfixadmin
Roundcube:http://trac.roundcube.net/wiki/Plugin_Repository
managesieve
sudo
yum -y install
dovecot-pigeonhole
dovecot
/etc/dovecot/dovecot.conf:
sudo gedit /etc/dovecot/dovecot.conf
protocols = pop3 imap sieve
etc/dovecot/conf.d/15-lda.conf
dovecot
/etc/dovecot/dovecot.conf:
sudo gedit /etc/dovecot/dovecot.conf
protocols = pop3 imap sieve
etc/dovecot/conf.d/15-lda.conf
sudo
gedit /etc/dovecot/conf.d/15-lda.conf
mail_plugins = quota sieve
dovecot
sudo service dovecot restart
Dovecot 4190:
netstat -tunlp | grep 4190
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 2188/dovecot
managesieve config.inc.php,:
[root@mail config]#cd /var/www/html/roundcubemail/plugins/managesieve/
[root@mail managesieve]# cp config.inc.php.dist config.inc.php
[root@mail managesieve]# gedit config.inc.php
$rcmail_config['managesieve_port'] = 4190;
/var/www/html/config/main.inc.php
sudo gedit /var/www/html/roundcubemail/config/main.inc.php
$rcmail_config['plugins'] = array('managesieve');
Managesieve
Roundcube Webmail :http://blog.dvxj.com/pandola/roundcube-webmail-plugins.html
$rcmail_config['plugins'] = array('managesieve','password','filesystem_attachments', 'emoticons', 'example_addressbook', 'message_highlight','jqueryui','globaladdressbook','userinfo','markasjunk','enigma','vcard_attachments','help');
sudo cp -rf /home/pandy/下载/global-address-book /var/www/html/roundcubemail/plugins/
compose_addressbook: sudo cp -rf /home/pandy/下载/compose_addressbook /var/www/html/roundcubemail/plugins/
message_highlight:
sudo cp -rf /home/pandy/下载/message_highlight /var/www/html/roundcubemail/plugins/
sudo gedit /var/www/html/roundcubemail/config/main.inc.php
$rcmail_config['skin'] = 'larry'; // $rcmail_config['skin'] = 'classic';
sudo gedit /etc/dovecot/dovecot.conf
# If you want to specify ports for each service, you will need to configure
# these settings inside the protocol imap/pop3 { ... } section, so you can
# specify different ports for IMAP/POP3. For example:
# protocol imap {
# listen = *:10143
# ssl_listen = *:10943
# ..
# }
# protocol pop3 {
# listen = *:10100
# ..
# }
If you get errors Mailbox doesn't exist: INBOX
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:%hMaildir, 4httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
mail_plugins = quota sieve
dovecot
sudo service dovecot restart
Dovecot 4190:
netstat -tunlp | grep 4190
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 2188/dovecot
managesieve config.inc.php,:
[root@mail config]#cd /var/www/html/roundcubemail/plugins/managesieve/
[root@mail managesieve]# cp config.inc.php.dist config.inc.php
[root@mail managesieve]# gedit config.inc.php
$rcmail_config['managesieve_port'] = 4190;
/var/www/html/config/main.inc.php
sudo gedit /var/www/html/roundcubemail/config/main.inc.php
$rcmail_config['plugins'] = array('managesieve');
Managesieve
Roundcube Webmail :http://blog.dvxj.com/pandola/roundcube-webmail-plugins.html
$rcmail_config['plugins'] = array('managesieve','password','filesystem_attachments', 'emoticons', 'example_addressbook', 'message_highlight','jqueryui','globaladdressbook','userinfo','markasjunk','enigma','vcard_attachments','help');
sudo cp -rf /home/pandy/下载/global-address-book /var/www/html/roundcubemail/plugins/
compose_addressbook: sudo cp -rf /home/pandy/下载/compose_addressbook /var/www/html/roundcubemail/plugins/
message_highlight:
sudo cp -rf /home/pandy/下载/message_highlight /var/www/html/roundcubemail/plugins/
sudo gedit /var/www/html/roundcubemail/config/main.inc.php
$rcmail_config['skin'] = 'larry'; // $rcmail_config['skin'] = 'classic';
sudo gedit /etc/dovecot/dovecot.conf
# If you want to specify ports for each service, you will need to configure
# these settings inside the protocol imap/pop3 { ... } section, so you can
# specify different ports for IMAP/POP3. For example:
# protocol imap {
# listen = *:10143
# ssl_listen = *:10943
# ..
# }
# protocol pop3 {
# listen = *:10100
# ..
# }
If you get errors Mailbox doesn't exist: INBOX
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:%hMaildir, 4httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
:/etc/httpd/conf/httpd.conf
5. :sudo gedit /var/log/maillog
6.:
Error: user test@pandy8.com: Initialization failed: Initializing mail storage from mail_location setting failed: mkdir(/var/vmail/pandy8.com/test/Maildir) failed: Permission denied (euid=2000(vmail) egid=2000(vmail) missing +w perm: /var/vmail/pandy8.com, euid is not dir owner)
7. :
postfix/local[2670]: 74CD9281454: to=<test@pandy8.com>, relay=local, delay=0.33, delays=0.11/0.17/0/0.05, dsn=5.1.1, status=bounced (unknown user: "test")
http://stackoverflow.com/questions/18377813/postfix-status-bounced-unknown-user-myuser
mydestination = localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
5. :sudo gedit /var/log/maillog
6.:
Error: user test@pandy8.com: Initialization failed: Initializing mail storage from mail_location setting failed: mkdir(/var/vmail/pandy8.com/test/Maildir) failed: Permission denied (euid=2000(vmail) egid=2000(vmail) missing +w perm: /var/vmail/pandy8.com, euid is not dir owner)
7. :
postfix/local[2670]: 74CD9281454: to=<test@pandy8.com>, relay=local, delay=0.33, delays=0.11/0.17/0/0.05, dsn=5.1.1, status=bounced (unknown user: "test")
http://stackoverflow.com/questions/18377813/postfix-status-bounced-unknown-user-myuser
mydestination = localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain