首页 > 数据库 >CentOS6.4邮件配置一: postfix + dovecot + mysql + postfixadmin + Roundcubemail

CentOS6.4邮件配置一: postfix + dovecot + mysql + postfixadmin + Roundcubemail

时间:2023-09-14 17:03:48浏览次数:52  
标签:postfix sudo gedit Roundcubemail darkblue mysql dovecot color


参考文章:
----------------------------

[size=large][color=red]可以考虑:[/color][/size]
Posty —— Postfix 和 Dovecot 的管理工具 [url][/url]
Posty 是一款基于 Web 的 Postfix & Dovecot 管理工具,功能模块包括:API、CLI 和 WebUI。

基于Centos6.2 X64系统下的邮件系统(一) [url]http://205498.blog.51cto.com/195498/844868[/url]
基于Centos6.2 X64系统下的邮件系统(二)[url]http://205498.blog.51cto.com/195498/844877[/url] 包含杀毒等软件的安装
hmailServer搭建(整合roundcubemail和squirrelmail)[url]http://www.360doc.com/content/10/1109/13/4171006_67887489.shtml[/url]
[color=red] Postfix指定smtp认证客户端发送邮件不成功?[/color]
[url]http://bbs.chinaunix.net/thread-4099484-1-1.html[/url]

构建Linux系统下的安全Postfix电子邮件服务 [url]http://www.searchsecurity.com.cn/showcontent_73728.htm

如果需要配置DNS,可以参考: [url]http://panyongzheng.iteye.com/blog/1882011[/url]

[color=red][b]注意:重启,要检查resolv.conf问题[/b][/color]

[b][size=large][color=red]关闭/禁用SELinux[/color][/size][/b]
sudo gedit /etc/selinux/config
修改成 SELINUX=disable 禁用SeLinux;修改成 SELINUX=enforcing 使用SeLinux
[color=red]主意,这个会引起后面的第6个问题。[/color]

CentOS安装扩展:
[color=darkblue]sudo yum install gcc kernel-devel kernel-headers dkms make bzip2 perl[/color]

[b][color=red]配置iptables:[/color][/b]
[color=darkblue]sudo gedit /etc/sysconfig/iptables[/color]
-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
[color=darkblue]sudo service iptables restart[/color]

[color=red][b]软件安装:[/b][/color]
[color=darkblue]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 [/color]
[color=red]注意:以上自动开机运行和启动服务很重要,否则可能会碰到乱七八糟的问题[/color]

[color=red][b]创建一个vmail用户[/b][/color],用作管理虚拟邮箱的文件夹
[color=darkblue]sudo useradd -u 2000 -d /var/vmail -m -s /sbin/nologin vmail[/color]

[color=red][b]创建mail数据库和账户[/b][/color]:
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;

[color=red][b]下载postfixadmin:[/b][/color]
[url]http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-2.3.6/postfixadmin-2.3.6.tar.gz/download[/url]
解压,并重命名:postfixadmin,复制到/var/www/html
[color=darkblue]sudo cp -rf /home/pandy/下载/postfixadmin /var/www/html[/color]

[color=red][b]修改postfixadmin配置文件:[/b][/color]
[color=darkblue]sudo gedit /var/www/html/postfixadmin/config.inc.php[/color]
------------
[color=darkblue]$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'] = '[email protected]';
$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';[/color]

[color=red][b]进入postfixadmin:[/b][/color]
[url]http://127.0.0.1/postfixadmin/setup.php[/url]
输入:admin / admin, generate password hash, 跳转到第二部, 得到一个hash code,
复制这个code,并修改:sudo gedit /var/www/html/postfixadmin/config.inc.php
$CONF['setup_password'] = 'ae3e1cb27c62fae6c43dc1fd84853207:03bf21e651640880b910317a27fdb205fe8949fa'; //这个值是根据你的输入变化的
然后继续其他设定,[color=red][b]注意,先不创建管理员账户,以后再创建。[/b][/color]


[color=red][b]postfixadmin[/b][/color]
=================================
[color=red][b]postfxiadmin不能自动创建目录,增加自动建立目录的功能[/b][/color]
建立创建虚拟邮箱脚本,脚本名称 /usr/local/bin/maildir-creation.sh ,脚本内容如下:
[color=darkblue]sudo gedit /usr/local/bin/maildir-creation.sh[/color]
--------------------------------------------
[color=darkblue]#!/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[/color]

建立删除虚拟邮箱脚本,脚本名称 /usr/local/bin/maildir-deletion.sh ,脚本内容如下:
[color=darkblue]sudo gedit /usr/local/bin/maildir-deletion.sh[/color]
----------------------------------------------
[color=darkblue]#!/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[/color]

建立删除目录
[color=darkblue]sudo mkdir /var/vmail/deleted-maildirs
sudo chown -R vmail.vmail /var/vmail/deleted-maildirs/[/color]

赋予脚本可执行权限
[color=darkblue]sudo chmod 750 /usr/local/bin/maildir-*
sudo chown vmail.vmail /usr/local/bin/maildir-*[/color]

配置sudo
在 /etc/sudoers 增加一行
[color=darkblue]sudo vim /etc/sudoers[/color]
----------------------------
vmail ALL = NOPASSWD: /usr/local/bin/maildir-creation.sh
vmail ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
注释掉下面内容
#Defaults requiretty
esc , :wq!, 强制保存


[color=darkblue][b]修改postfixadmin的相关文件[/b][/color]
修改[color=red]create-mailbox.php[/color] 文件,229行内容应该是:
[color=darkblue]sudo gedit /var/www/html/postfixadmin/create-mailbox.php[/color]
db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");
在该行前面增加下面一行:
[color=darkblue]system("sudo /usr/local/bin/maildir-creation.sh $fDomain ".$_POST['fUsername']);[/color]

修改[color=red]delete.php[/color] 文件,146行内容应该是:
[color=darkblue]sudo gedit /var/www/html/postfixadmin/delete.php[/color]
db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete);
在该行下面增加下面4行:
[color=darkblue]$userarray=explode("@",$fDelete);
$user=$userarray[0];
$domain=$userarray[1];
system("sudo /usr/local/bin/maildir-deletion.sh $domain $user");[/color]


[b][color=red]4、配置Postfix[/color][/b]

=========================================
[color=darkblue]修改/etc/postfix/main.cf文件[/color]:
[color=darkblue]sudo gedit /etc/postfix/main.cf[/color]
[color=red]基本配置[/color]
---------------------------------------以下修改
[color=darkblue]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[/color]

[color=red]虚拟域名配置[/color]
---------------------------------------以下增加
[color=darkblue]#=======================================================================
# 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[/color]

[color=red]SMTP加密设定[/color]
---------------------------------------
[color=darkblue]#=======================================================================
#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[/color]

[color=red]使用Dovecot做为投递[/color]
---------------------------------------
[color=darkblue]#=======================================================================
# TRANSPORT MAP
#
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1[/color]


[b][color=darkblue]修改master.cf文件[/color][/b]
[color=darkblue]sudo gedit /etc/postfix/master.cf[/color]
在底部增加
---------------------------------------
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}


[color=red][b]创建Mysql脚本[/b][/color]
==================================
[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_domains_maps.cf[/color]
---------------------------------------
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'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_alias_maps.cf[/color]
----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_mailbox_maps.cf[/color]
-----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_mailbox_limit_maps.cf[/color]
--------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'


[b][color=red]5、配置Dovecot[/color][/b]
================================================
因为配置文件比较分散,我把需要修改的配置文件的内容列出来
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
---------------------------------

protocols = imap pop3

listen = *

dict {

 quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext

}

!include conf.d/*.conf



[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-auth.conf[/color]
---------------------------------
disable_plaintext_auth = no
auth_mechanisms = plain login cram-md5
!include auth-sql.conf.ext

[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-mail.conf[/color]
--------------------------------
mail_location = maildir:%hMaildir
mbox_write_locks = fcntl

[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-master.conf[/color]
---------------------------

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

 }

}



[color=darkblue]sudo gedit /etc/dovecot/conf.d/15-lda.conf[/color]
---------------------

protocol lda {

 mail_plugins = quota

 postmaster_address = [email protected]

}



[color=darkblue]sudo gedit /etc/dovecot/conf.d/20-imap.conf[/color]
-----------------------------

protocol imap {

 mail_plugins = quota imap_quota

}

[color=darkblue]


sudo gedit /etc/dovecot/conf.d/20-pop3.conf[/color]
------------------------------

protocol pop3 {

 pop3_uidl_format = %08Xu%08Xv

 mail_plugins = quota

}


[color=darkblue]sudo gedit /etc/dovecot/conf.d/90-quota.conf[/color]
----------------------------

plugin {

 quota_rule = *:storage=1G

}

plugin {

}

plugin {

 quota = dict:User quota::proxy::quota

}

plugin {

}



[color=darkblue]sudo gedit /etc/dovecot/dovecot-sql.conf.ext[/color]
--------------------------
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'

[color=darkblue]sudo gedit /etc/dovecot/dovecot-dict-sql.conf.ext[/color]
-----------------------------

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

}



[color=darkblue]sudo gedit /etc/pam.d/dovecot[/color]
-------------------------
#%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

[color=darkblue]重启CentOS:reboot[/color]

[color=red]测试监听:[/color]
netstat -tlunp | grep ':25'
netstat -tlunp | grep ':110'
sudo postfix check //没返回任何信息,就是最好
sudo tail 0f /var/log/maillog //查看maillog

再次进入:[url]http://127.0.0.1/postfixadmin/setup.php[/url]
输入:admin, [email protected], admin, admin
显示:新增管理员成功!,([email protected]), 增加管理员成功;
进入:[url]http://127.0.0.1/postfixadmin/login.php[/url]
[color=darkblue]使用管理员和密码进入:[email protected]/admin,
增加一个:pandy8.com的域名;
增加一个邮箱:[email protected][/color]

[color=red]测试发件:[/color]
[pandy@localhost ~]$ [color=darkblue]telnet localhost 25[/color]
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 bogon ESMTP Postfix
[color=darkblue]ehlo [email protected][/color]<---输入内容
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
[color=darkblue]quit[/color]


测试收件:
[pandy@bogon ~]$ [color=darkblue]telnet localhost 110[/color]
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
[color=darkblue]user [email protected][/color]<---输入内容
+OK
[color=darkblue]pass test[/color]<---输入内容
+OK Logged in.
[color=darkblue]quit[/color]<---输入内容
+OK Logging out.
Connection closed by foreign host.


[color=red][b]安装roundcubemail[/b][/color]
===================================
下载位置,可能要跳墙才能下载
[url]http://superb-dca2.dl.sourceforge.net/project/roundcubemail/roundcubemail/0.9.1/roundcubemail-0.9.1.tar.gz[/url]
解压,重新命名:roundcubemail,并复制到html文件夹
[color=darkblue]sudo cp -rf /home/pandy/下载/roundcubemail /var/www/html/[/color]

[color=darkblue]建立roundcubemail数据库和Mysql用户[/color]
mysql -h localhost -uroot -p
mysql> CREATE DATABASE roundcubemail;
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'pa5swd';
mysql> flush privileges;

[color=darkblue]安装mysql工具,来执行sql:[/color]
下载位置:[url]http://dev.mysql.com/downloads/tools/workbench/[/url]
或者:[url]http://download.softagency.net/MySQL/Downloads/MySQLGUITools/[/url]
使用这个工具执行:roundcubemail/SQL/mysql.initial.sql
[color=red]注意,是使用roundcubemail账户和密码进去执行[/color]

[color=darkblue]配置Roundcubemail[/color]
配置数据库配置文件
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';

[color=darkblue]配置主配置文件[/color]
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';

[color=darkblue]重新启动httpd服务:[/color]
sudo service httpd restart;

进入:[url]http://127.0.0.1/roundcubemail/[/url]
使用上面创建的:[email protected]/test进入

查看收件箱,就能看到创建帐号自动发送的邮件,如果没有,那么到postfixadmin里面去尝试发送一个,就看见了。

[color=blue][b]Roundcube邮件系统的插件[/b][/color]:[url]http://trac.roundcube.net/wiki/Plugin_Repository
[b][color=red]配置managesieve插件[/color][/b], 提供过滤器,假期回复
[color=darkblue]sudo yum -y install dovecot-pigeonhole[/color]

[b]配置dovecot配置文件[/b]
修改/etc/dovecot/dovecot.conf文件,做如下修改:
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
protocols = pop3 imap sieve

修改/etc/dovecot/conf.d/15-lda.conf文件,做如下修改:
[color=darkblue]sudo gedit /etc/dovecot/conf.d/15-lda.conf[/color]
mail_plugins = quota sieve

[b]重新启动dovecot[/b]
[color=darkblue]sudo service dovecot restart[/color]

[b]Dovecot监听4190端口[/b]:
[color=darkblue]netstat -tunlp | grep 4190[/color]
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 2188/dovecot

[b]managesieve配置文件[/b]修改,将模板复制成config.inc.php,做如下修改:
#[color=darkblue]cd /var/www/html/roundcubemail/plugins/managesieve/[/color]
# [color=darkblue]cp config.inc.php.dist config.inc.php[/color]
# [color=darkblue]gedit config.inc.php[/color]
修改以下内容:
[color=darkblue]$rcmail_config['managesieve_port'] = 4190;[/color]

[b]使插件生效[/b]
修改/var/www/html/config/main.inc.php文件
[color=darkblue]sudo gedit /var/www/html/roundcubemail/config/main.inc.php[/color]
修改以下内容:
[color=darkblue]$rcmail_config['plugins'] = array('managesieve');[/color]

[b]测试插件[/b]
Managesieve界面
[img]http://img1.51cto.com/attachment/201204/140158252.png[/img]
[color=darkblue]更多插件的配置见[/color]:
Roundcube Webmail 多域及插件配置篇:[url]http://blog.dvxj.com/pandola/roundcube-webmail-plugins.html[/url]
$rcmail_config['plugins'] = array('managesieve','password','filesystem_attachments', 'emoticons', 'example_addressbook', 'message_highlight','jqueryui','globaladdressbook','userinfo','markasjunk','enigma','vcard_attachments','help');
加了6个插件,为啥是6个,因为那个jqueryui是其他插件要用的脚本,所以具体插件数目是6个,array圆括号内的参数,单引号引起来的,比如'password',引号内的内容,一定是和plugins目录中插件目录名一致,这样Roundcube才会根据配置,加载相应的插件。
globaladdressbook:全局地址簿,这个功能其实不错,可以让域管理员统一提前配置好公司所有人的邮件地址,这样大家发邮件的时候就可以使用现成的了。当然,这个不影响每个用户自己私人的地址簿,是分开的。
[color=darkblue]sudo cp -rf /home/pandy/下载/global-address-book /var/www/html/roundcubemail/plugins/[/color]
compose_addressbook:是写邮件时,可以通过点击一个按钮,弹出窗口调出地址簿,让你选择收件人,抄送、密送等邮件地址;
[color=darkblue]sudo cp -rf /home/pandy/下载/compose_addressbook /var/www/html/roundcubemail/plugins/[/color]
message_highlight: 高亮显示
[color=darkblue]sudo cp -rf /home/pandy/下载/message_highlight /var/www/html/roundcubemail/plugins/[/color]
[color=red]注意,这些名字在下载后是有修改过的,有些没配置成功,那就像钓@鱼@岛问题一样,留给后人。[/color]


[color=red][b]皮肤:[/b][/color]
[color=darkblue]sudo gedit /var/www/html/roundcubemail/config/main.inc.php[/color]
$rcmail_config['skin'] = 'larry'; //默认皮肤
$rcmail_config['skin'] = 'classic';


[b][color=red]修改端口:[/color][/b]
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
里面有说明:

# 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

# ..

# }



[color=red][b]问题:[/b][/color]
[b]1. dovecot测试 -ERR Authentication failed[/b]

[b]2. Connection closed by foreign host[/b]
确保运行dovecot服务,sudo chkconfig postfix on , service dovecot restart;
[url]http://www.pooy.net/connection-closed-foreign-host.html[/url]
造成这个原 因是因为原来连接到SSHD服务器进程的22端口,当你的客户端突然断开时,服务器端的TCP连接就处于一个半打开状态。当下一次同一客户机再次建立 TCP连接时,服务器检测到这个半打开的TCP连接,并向客户机回传一个置位RST的TCP报文,客户机就会显示connection closed by foreign host。
这是TCP协议本身的一个保护措施,并不是什么错误,你只要再重新连接服务器就能连上。
我用的是wifi,然后登录路由之后,断网,自动的重新链接即可了!

[b]3. Mailbox doesn't exist: INBOX[/b]
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:%hMaildir, 否则会报这个错误

[b]4.解决httpd[/b]: Could not reliably determine the server's fully qualified domain name, [b]using 127.0.0.1 for ServerName[/b]
配置文件:/etc/httpd/conf/httpd.conf

[b]5. 日志文件[/b]:sudo gedit /var/log/maillog

[b]6. 收信不成功,看后台日志:[/b]
Error: user [email protected]: 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)

[b]7. 收信不成功,看后台日志:[/b]
postfix/local[2670]: 74CD9281454: to=<[email protected]>, relay=local, delay=0.33, delays=0.11/0.17/0/0.05, dsn=5.1.1, status=bounced (unknown user: "test")
[url]http://stackoverflow.com/questions/18377813/postfix-status-bounced-unknown-user-myuser[/url]
mydestination = localhost //使用这个
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //注释掉这个。


[b]8. Foxmail链接[/b]
[url]http://www.extmail.net/forum/viewthread.php?tid=24693&page=1
改成
inet_interfaces = all
mynetworks = 127.0.0.1,192.168.1.0/24
客户端===>让软件自动寻找也可以
pop.pandy8.com、pop3.pandy8.com
smtp.pandy8.com
sudo chkconfig dovecot on
sudo chkconfig httpd on
sudo chkconfig mysqld on
sudo service postfix restart
sudo service dovecot restart
sudo service httpd restart
sudo service mysqld restart [/color]
[color=red]注意:以上自动开机运行和启动服务很重要,否则可能会碰到乱七八糟的问题[/color]

[color=red][b]创建一个vmail用户[/b][/color],用作管理虚拟邮箱的文件夹
[color=darkblue]sudo useradd -u 2000 -d /var/vmail -m -s /sbin/nologin vmail[/color]

[color=red][b]创建mail数据库和账户[/b][/color]:
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;

[color=red][b]下载postfixadmin:[/b][/color]
[url]http://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-2.3.6/postfixadmin-2.3.6.tar.gz/download[/url]
解压,并重命名:postfixadmin,复制到/var/www/html
[color=darkblue]sudo cp -rf /home/pandy/下载/postfixadmin /var/www/html[/color]

[color=red][b]修改postfixadmin配置文件:[/b][/color]
[color=darkblue]sudo gedit /var/www/html/postfixadmin/config.inc.php[/color]
------------

[color=darkblue]$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'] = '[email protected]';

$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['quota'] = 'YES';

$CONF['used_quotas'] = 'YES';

$CONF['new_quota_table'] = 'YES';[/color]



[color=red][b]进入postfixadmin:[/b][/color]
[url]http://127.0.0.1/postfixadmin/setup.php[/url]
输入:admin / admin, generate password hash, 跳转到第二部, 得到一个hash code,
复制这个code,并修改:sudo gedit /var/www/html/postfixadmin/config.inc.php
$CONF['setup_password'] = 'ae3e1cb27c62fae6c43dc1fd84853207:03bf21e651640880b910317a27fdb205fe8949fa'; //这个值是根据你的输入变化的
然后继续其他设定,[color=red][b]注意,先不创建管理员账户,以后再创建。[/b][/color]


[color=red][b]postfixadmin[/b][/color]
=================================
[color=red][b]postfxiadmin不能自动创建目录,增加自动建立目录的功能[/b][/color]
建立创建虚拟邮箱脚本,脚本名称 /usr/local/bin/maildir-creation.sh ,脚本内容如下:
[color=darkblue]sudo gedit /usr/local/bin/maildir-creation.sh[/color]
--------------------------------------------

[color=darkblue]#!/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[/color]



建立删除虚拟邮箱脚本,脚本名称 /usr/local/bin/maildir-deletion.sh ,脚本内容如下:
[color=darkblue]sudo gedit /usr/local/bin/maildir-deletion.sh[/color]
----------------------------------------------

[color=darkblue]#!/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[/color]



建立删除目录
[color=darkblue]sudo mkdir /var/vmail/deleted-maildirs
sudo chown -R vmail.vmail /var/vmail/deleted-maildirs/[/color]

赋予脚本可执行权限
[color=darkblue]sudo chmod 750 /usr/local/bin/maildir-*
sudo chown vmail.vmail /usr/local/bin/maildir-*[/color]

配置sudo
在 /etc/sudoers 增加一行
[color=darkblue]sudo vim /etc/sudoers[/color]
----------------------------
vmail ALL = NOPASSWD: /usr/local/bin/maildir-creation.sh
vmail ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh
注释掉下面内容
#Defaults requiretty
esc , :wq!, 强制保存


[color=darkblue][b]修改postfixadmin的相关文件[/b][/color]
修改[color=red]create-mailbox.php[/color] 文件,229行内容应该是:
[color=darkblue]sudo gedit /var/www/html/postfixadmin/create-mailbox.php[/color]
db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");
在该行前面增加下面一行:
[color=darkblue]system("sudo /usr/local/bin/maildir-creation.sh $fDomain ".$_POST['fUsername']);[/color]

修改[color=red]delete.php[/color] 文件,146行内容应该是:
[color=darkblue]sudo gedit /var/www/html/postfixadmin/delete.php[/color]
db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete);
在该行下面增加下面4行:
[color=darkblue]$userarray=explode("@",$fDelete);
$user=$userarray[0];
$domain=$userarray[1];
system("sudo /usr/local/bin/maildir-deletion.sh $domain $user");[/color]


[b][color=red]4、配置Postfix[/color][/b]
=========================================
[color=darkblue]修改/etc/postfix/main.cf文件[/color]:
[color=darkblue]sudo gedit /etc/postfix/main.cf[/color]
[color=red]基本配置[/color]
---------------------------------------以下修改
[color=darkblue]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[/color]

[color=red]虚拟域名配置[/color]
---------------------------------------以下增加
[color=darkblue]#=======================================================================
# 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[/color]

[color=red]SMTP加密设定[/color]
---------------------------------------
[color=darkblue]#=======================================================================
#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[/color]

[color=red]使用Dovecot做为投递[/color]
---------------------------------------
[color=darkblue]#=======================================================================
# TRANSPORT MAP
#
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1[/color]


[b][color=darkblue]修改master.cf文件[/color][/b]
[color=darkblue]sudo gedit /etc/postfix/master.cf[/color]
在底部增加
---------------------------------------
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}


[color=red][b]创建Mysql脚本[/b][/color]
==================================
[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_domains_maps.cf[/color]
---------------------------------------
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'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_alias_maps.cf[/color]
----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_mailbox_maps.cf[/color]
-----------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'

[color=darkblue]sudo gedit /etc/postfix/mysql_virtual_mailbox_limit_maps.cf[/color]
--------------------------------------
user = admin
password = 123123
hosts = localhost
dbname = mail
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'


[b][color=red]5、配置Dovecot[/color][/b]
================================================
因为配置文件比较分散,我把需要修改的配置文件的内容列出来
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
---------------------------------

protocols = imap pop3

listen = *

dict {

 quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext

}

!include conf.d/*.conf



[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-auth.conf[/color]
---------------------------------
disable_plaintext_auth = no
auth_mechanisms = plain login cram-md5
!include auth-sql.conf.ext

[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-mail.conf[/color]
--------------------------------
mail_location = maildir:%hMaildir
mbox_write_locks = fcntl

[color=darkblue]sudo gedit /etc/dovecot/conf.d/10-master.conf[/color]
---------------------------

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

 }

}



[color=darkblue]sudo gedit /etc/dovecot/conf.d/15-lda.conf[/color]
---------------------

protocol lda {

 mail_plugins = quota

 postmaster_address = [email protected]

}



[color=darkblue]sudo gedit /etc/dovecot/conf.d/20-imap.conf[/color]
-----------------------------

protocol imap {

 mail_plugins = quota imap_quota

}

[color=darkblue]

sudo gedit /etc/dovecot/conf.d/20-pop3.conf[/color]


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

protocol pop3 {

 pop3_uidl_format = %08Xu%08Xv

 mail_plugins = quota

}



[color=darkblue]sudo gedit /etc/dovecot/conf.d/90-quota.conf[/color]
----------------------------

plugin {

 quota_rule = *:storage=1G

}

plugin {

}

plugin {

 quota = dict:User quota::proxy::quota

}

plugin {

}



[color=darkblue]sudo gedit /etc/dovecot/dovecot-sql.conf.ext[/color]
--------------------------
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'

[color=darkblue]sudo gedit /etc/dovecot/dovecot-dict-sql.conf.ext[/color]
-----------------------------

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

}



[color=darkblue]sudo gedit /etc/pam.d/dovecot[/color]
-------------------------
#%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

[color=darkblue]重启CentOS:reboot[/color]

[color=red]测试监听:[/color]
netstat -tlunp | grep ':25'
netstat -tlunp | grep ':110'
sudo postfix check //没返回任何信息,就是最好
sudo tail 0f /var/log/maillog //查看maillog

再次进入:[url]http://127.0.0.1/postfixadmin/setup.php[/url]
输入:admin, [email protected], admin, admin
显示:新增管理员成功!,([email protected]), 增加管理员成功;
进入:[url]http://127.0.0.1/postfixadmin/login.php[/url]
[color=darkblue]使用管理员和密码进入:[email protected]/admin,
增加一个:pandy8.com的域名;
增加一个邮箱:[email protected][/color]

[color=red]测试发件:[/color]
[pandy@localhost ~]$ [color=darkblue]telnet localhost 25[/color]
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 bogon ESMTP Postfix
[color=darkblue]ehlo [email protected][/color]<---输入内容
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
[color=darkblue]quit[/color]


测试收件:
[pandy@bogon ~]$ [color=darkblue]telnet localhost 110[/color]
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
[color=darkblue]user [email protected][/color]<---输入内容
+OK
[color=darkblue]pass test[/color]<---输入内容
+OK Logged in.
[color=darkblue]quit[/color]<---输入内容
+OK Logging out.
Connection closed by foreign host.


[color=red][b]安装roundcubemail[/b][/color]
===================================
下载位置,可能要跳墙才能下载
[url]http://superb-dca2.dl.sourceforge.net/project/roundcubemail/roundcubemail/0.9.1/roundcubemail-0.9.1.tar.gz[/url]
解压,重新命名:roundcubemail,并复制到html文件夹
[color=darkblue]sudo cp -rf /home/pandy/下载/roundcubemail /var/www/html/[/color]

[color=darkblue]建立roundcubemail数据库和Mysql用户[/color]
mysql -h localhost -uroot -p
mysql> CREATE DATABASE roundcubemail;
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'pa5swd';
mysql> flush privileges;

[color=darkblue]安装mysql工具,来执行sql:[/color]
下载位置:[url]http://dev.mysql.com/downloads/tools/workbench/[/url]
或者:[url]http://download.softagency.net/MySQL/Downloads/MySQLGUITools/[/url]
使用这个工具执行:roundcubemail/SQL/mysql.initial.sql
[color=red]注意,是使用roundcubemail账户和密码进去执行[/color]

[color=darkblue]配置Roundcubemail[/color]
配置数据库配置文件
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';

[color=darkblue]配置主配置文件[/color]
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';

[color=darkblue]重新启动httpd服务:[/color]
sudo service httpd restart;

进入:[url]http://127.0.0.1/roundcubemail/[/url]
使用上面创建的:[email protected]/test进入

查看收件箱,就能看到创建帐号自动发送的邮件,如果没有,那么到postfixadmin里面去尝试发送一个,就看见了。


[color=blue][b]Roundcube邮件系统的插件[/b][/color]:[url]http://trac.roundcube.net/wiki/Plugin_Repository
[b][color=red]配置managesieve插件[/color][/b], 提供过滤器,假期回复
[color=darkblue]sudo yum -y install dovecot-pigeonhole[/color]

[b]配置dovecot配置文件[/b]
修改/etc/dovecot/dovecot.conf文件,做如下修改:
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
protocols = pop3 imap sieve

修改/etc/dovecot/conf.d/15-lda.conf文件,做如下修改:
[color=darkblue]sudo gedit /etc/dovecot/conf.d/15-lda.conf[/color]
mail_plugins = quota sieve

[b]重新启动dovecot[/b]
[color=darkblue]sudo service dovecot restart[/color]

[b]Dovecot监听4190端口[/b]:
[color=darkblue]netstat -tunlp | grep 4190[/color]
tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 2188/dovecot

[b]managesieve配置文件[/b]修改,将模板复制成config.inc.php,做如下修改:
#[color=darkblue]cd /var/www/html/roundcubemail/plugins/managesieve/[/color]
# [color=darkblue]cp config.inc.php.dist config.inc.php[/color]
# [color=darkblue]gedit config.inc.php[/color]
修改以下内容:
[color=darkblue]$rcmail_config['managesieve_port'] = 4190;[/color]

[b]使插件生效[/b]
修改/var/www/html/config/main.inc.php文件
[color=darkblue]sudo gedit /var/www/html/roundcubemail/config/main.inc.php[/color]
修改以下内容:
[color=darkblue]$rcmail_config['plugins'] = array('managesieve');[/color]

[b]测试插件[/b]
Managesieve界面

CentOS6.4邮件配置一: postfix + dovecot + mysql + postfixadmin + Roundcubemail_数据库


[color=darkblue]更多插件的配置见[/color]:
Roundcube Webmail 多域及插件配置篇:[url]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');
加了6个插件,为啥是6个,因为那个jqueryui是其他插件要用的脚本,所以具体插件数目是6个,array圆括号内的参数,单引号引起来的,比如'password',引号内的内容,一定是和plugins目录中插件目录名一致,这样Roundcube才会根据配置,加载相应的插件。
globaladdressbook:全局地址簿,这个功能其实不错,可以让域管理员统一提前配置好公司所有人的邮件地址,这样大家发邮件的时候就可以使用现成的了。当然,这个不影响每个用户自己私人的地址簿,是分开的。
[color=darkblue]sudo cp -rf /home/pandy/下载/global-address-book /var/www/html/roundcubemail/plugins/[/color]
compose_addressbook:是写邮件时,可以通过点击一个按钮,弹出窗口调出地址簿,让你选择收件人,抄送、密送等邮件地址;
[color=darkblue]sudo cp -rf /home/pandy/下载/compose_addressbook /var/www/html/roundcubemail/plugins/[/color]
message_highlight: 高亮显示
[color=darkblue]sudo cp -rf /home/pandy/下载/message_highlight /var/www/html/roundcubemail/plugins/[/color]
[color=red]注意,这些名字在下载后是有修改过的,有些没配置成功,那就像钓@鱼@岛问题一样,留给后人。[/color]


[color=red][b]皮肤:[/b][/color]
[color=darkblue]sudo gedit /var/www/html/roundcubemail/config/main.inc.php[/color]
$rcmail_config['skin'] = 'larry'; //默认皮肤
$rcmail_config['skin'] = 'classic';


[b][color=red]Claws Mail客户端连接:[/color][/b]
[b]前提:[/b]
CentOS6.4邮件配置二: Bind安装配置 DNS服务器 [url]http://panyongzheng.iteye.com/blog/1882011[/url]
CentOS6.4邮件配置三: 花生壳 + 自定义DNS解析 + Dovecot 配置收外网信件: [url]http://panyongzheng.iteye.com/blog/1883439[/url]
#sudo yum -y install claws-mail
帐号设置:
帐号名称:[email protected]
邮件地址:[email protected]
通信协议POP3:
接受服务器:pandy8.com
SMTP服务器(发送):pandy8.com
用户ID:pandy8.com
密码:**********
就可以了,在Windows下面差不多一样设置.


[b][color=red]修改端口:[/color][/b]
[color=darkblue]sudo gedit /etc/dovecot/dovecot.conf[/color]
里面有说明:

# 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

# ..

# }




[color=red][b]问题:[/b][/color]
[b]1. dovecot测试 -ERR Authentication failed[/b]

[b]2. Connection closed by foreign host[/b]
确保运行dovecot服务,sudo chkconfig postfix on , service dovecot restart;
[url]http://www.pooy.net/connection-closed-foreign-host.html
造成这个原 因是因为原来连接到SSHD服务器进程的22端口,当你的客户端突然断开时,服务器端的TCP连接就处于一个半打开状态。当下一次同一客户机再次建立 TCP连接时,服务器检测到这个半打开的TCP连接,并向客户机回传一个置位RST的TCP报文,客户机就会显示connection closed by foreign host。
这是TCP协议本身的一个保护措施,并不是什么错误,你只要再重新连接服务器就能连上。
我用的是wifi,然后登录路由之后,断网,自动的重新链接即可了!

[b]3. Mailbox doesn't exist: INBOX[/b]
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:%hMaildir, 否则会报这个错误

[b]4.解决httpd[/b]: Could not reliably determine the server's fully qualified domain name, [b]using 127.0.0.1 for ServerName[/b]
配置文件:/etc/httpd/conf/httpd.conf

[b]5. 日志文件[/b]:sudo gedit /var/log/maillog

[b]6. 收信不成功,看后台日志:[/b]
Error: user [email protected]: 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)

[b]7. 收信不成功,看后台日志:[/b]
postfix/local[2670]: 74CD9281454: to=<[email protected]>, relay=local, delay=0.33, delays=0.11/0.17/0/0.05, dsn=5.1.1, status=bounced (unknown user: "test")
[url]http://stackoverflow.com/questions/18377813/postfix-status-bounced-unknown-user-myuser
mydestination = localhost //使用这个
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //注释掉这个。


[b]8. 客户端连接[/b]
[url]http://www.extmail.net/forum/viewthread.php?tid=24693&page=1
#sudo gedit /etc/postfix/main.cf
改成:
inet_interfaces = all
mynetworks = 127.0.0.1,192.168.1.0/24
客户端===>让软件自动寻找也可以
pop.pandy8.com、pop3.pandy8.com
smtp.pandy8.com

[b]9.Linux下面使用Claws Mail发送邮件“[color=red]Relay access denied[/color]”[/b],客户端才有这个问题,roundcubemail是看不到这个问题的,因为roundcubemail是使用localhost来地址来发信。
修复Postfix 的Relay access denied问题 [url]http://laravel.iteye.com/blog/1928259
注意,[color=red]这个问题很奇怪[/color],在Linux下的Virsualbox出错,但是到Windows去启动Virsualbox并发送邮件,也会同时把出错的邮件一起发送。

标签:postfix,sudo,gedit,Roundcubemail,darkblue,mysql,dovecot,color
From: https://blog.51cto.com/u_3871599/7471611

相关文章

  • 【验】Postfix+Dovecot+MySQL搭建邮件服务器
    网上有很多使用Postfix搭建邮件服务器的文章,但目前貌似没有看到较为完整的一篇。本例将尝试在Ubuntu系统中使用Postfix+Dovecot+MySQL搭建邮件服务器。说到邮件服务器,网上有许多不同解决方案。Window操作系统下常见的邮件服务器有hMailServer、MailEnable、EVOMailServer、ApacheJ......
  • Linux中Postfix反病毒和垃圾邮件(十)
    摘自:http://www.ywnds.com/?p=1817 amavisd-newamavisd-new呼叫器是一个连接MTA和内容检测工具(诸如病毒扫描工具和SpamAssassin)的高性能接口程序,使用perl语言写成。它一般通过SMTP、ESMTP或者LMTP和MTA进行通讯,可以将位于队列的邮件取出来,调用ClamAV对邮件进行病毒扫描,调用Sp......
  • Linux中Postfix邮件认证配置(五)
    摘自:http://www.ywnds.com/?p=1784Postfix+Dovecot+Sasl工作原理1.A用户使用MUA客户端借助smtp协议登陆smtpd服务器,需要先进行用户和密码认证,而SMTPD服务器端支持sasl认证,例如有一个sasl客户端,就会去连接SASL。当SASL接受到验证请求时就会根据验证方式去进行验证,常用的有PAM,pass......
  • Linux中Postfix虚拟用户及虚拟域(六)
    摘自:http://www.ywnds.com/?p=1797 Postfix基于虚拟用户虚拟域的邮件架构 上图是一个几乎完整的邮件系统架构图,这里基于Mysql数据库进行用户认证,不管是Postfix、Dovecot、webmail都需要去Mysql数据库中进行用户认证。1、用户可以基于outlook连接postfix然后通过Courier-au......
  • Linux中Postfix邮件安装配置(二)
    摘自:http://www.ywnds.com/?p=1764Postfix安装配置本套邮件系统的搭建,从如何发邮件到收邮件到认证到虚拟用户虚拟域以及反病毒和反垃圾邮件等都有详细的介绍。在搭建过程中必须的参数解释以及原理都有告诉,这样才能更好地理解邮件系统。一、卸载自带postfix 123......
  • Postfix + Extmail 企业邮件服务器搭建
    ExtMail套件用于提供从浏览器中登录、使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面。它以GPL版权释出,设计初衷是希望设计一个适应当前高速发展的IT应用环境,满足用户多变的需求,能快速进行开发、改进和升级,适应能力强的webmail系统。Centos7安......
  • Linux中/var/spool/postfix/maildrop/占用inode索引及磁盘空间解决办法
    问题表现和检查:1.运行df-i查看inode使用是否满;2.查看/var/spool/postfix/maildrop是否有非常多的小文件,ls直接卡死等情况;解决:1、清空/var/spool/postfix/maildrop/目录下的内容cd/var/spool/postfix/maildrop/ls|xargsrm-f2、不让系统再发垃圾邮件vi/etc/crontab;将......
  • 搭建邮件服务器之使用Postfix收发邮件
    发邮件0x01安装postfixaptinstallpostifx弹窗中选择第二个,其他配置项内容如下Noconfiguration:表示不要做任何配置;InternetSite:表示直接使用本地SMTP服务器发送和接收邮件;Internetwithsmarthos:表示使用本地SMTP服务器接收邮件,但发送邮件时不直接使用本地SMTP服务器,......
  • 修改postfix/手工编译/安装让smtp日志包含mail from 信息
    修改后的日志to=变成[email protected]>这是sent日志Nov2112:56:27chrd-edmpostfix/smtp[11762]:208E0100735:[email protected]><[email protected]>,relay=mx3.qq.com[112.90.138.89]:25,delay=0.94,delays=0.09/0.01/0.51/0.33,dsn=2.0.0,status=sent(250......
  • 网络系统管理Linux环境——12.AppSrv之MAIL(POSTFIX-SMTPS & DOVECOT-IMAPS)
    题目要求服务器AppSrv上的工作任务5. MAIL(POSTFIX-SMTPS&DOVECOT-IMAPS)Postfix​​​sdskill.com​​​​​的邮件发送服务器支持smtps(465)协议连接,使用Rserver颁发......