安装邮件服务器之四

20、配置cyrus-sasl

为了支持maildrop,先加入vmail用户:

# pw adduser vmail -u 1003 -s /sbin/nologin -d /dev/null

你需要创建/usr/local/lib/sasl2/smtpd.conf:

# ee /usr/local/lib/sasl2/smtpd.conf

pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login

sql_engine: mysql
sql_hostnames: localhost
sql_user: postfix
sql_passwd: postfix
sql_database: postfix
sql_select: select clear from tmail_users where email='%u@%r' and smtpaccess='Y'

21、配置postfix

# ln -s /usr/local/sbin/sendmail /usr/sbin/sendmail

如果/usr/sbin/sendmail存在就删掉再做上链接,如果升级内核和升级系统后要重新做这一步

# echo 'postfix:root' >> /etc/aliases
# newaliases
# chown postfix:postfix /etc/opiekeys

编辑/usr/local/etc/postfix/main.cf:

# ee /usr/local/etc/postfix/main.cf

在文件最后加入以下内容,其中各个参数根据需要自己填写:

# new add
myhostname = mail.test.com  
smtp_helo_name = $myhostname

local_transport = maildrop
mailbox_transport = maildrop

smtpd_error_sleep_time = 0
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20
default_process_limit = 100
#alias_maps       = hash:/usr/local/etc/postfix/aliases
#Alias_database         = hash:/usr/local/etc/postfix/aliases
mydestination     =   mysql:/usr/local/etc/postfix/mysql-mydest.cf
virtual_transport_maps     = mysql:/usr/local/etc/postfix/mysql-transport.cf
virtual_alias_maps       = mysql:/usr/local/etc/postfix/mysql-virtual.cf
#virtual_alias_maps   = mysql:/usr/local/etc/postfix/mysql-alias.cf
recipient_bcc_maps = mysql:/usr/local/etc/postfix/mysql-autobbc-in.cf
sender_bcc_maps = mysql:/usr/local/etc/postfix/mysql-autobbc-out.cf
local_recipient_maps = $alias_maps $virtual_mailbox_maps $virtual_maps

virtual_mailbox_base = /mail
virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql-virtual-maps.cf
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/usr/local/etc/postfix/mysql-virtual-quota.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
virtual_uid_maps     = mysql:/usr/local/etc/postfix/mysql-virtual-uid.cf
virtual_gid_maps     = mysql:/usr/local/etc/postfix/mysql-virtual-gid.cf
broken_sasl_auth_clients   = yes
smtpd_sasl_auth_enable     = yes
smtpd_sasl_security_options = noanonymous
smtpd_client_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    check_client_access mysql:/usr/local/etc/postfix/mysql-access.cf,
    permit_auth_destination,
    reject
smtpd_sender_restrictions =
    reject_unknown_sender_domain,
    reject_non_fqdn_sender,
    check_sender_access mysql:/usr/local/etc/postfix/mysql-access.cf,
    permit
smtpd_recipient_restrictions =
    permit_mynetworks,
    check_client_access mysql:/usr/local/etc/postfix/mysql-access.cf,
    permit_sasl_authenticated,
    reject_non_fqdn_sender,
    reject_non_fqdn_recipient,
    reject_unknown_recipient_domain,
    reject_unauth_pipelining,
    reject_unauth_destination,
    reject_rbl_client cblless.anti-spam.org.cn,
    permit
default_destination_recipient_limit = 1
local_destination_concurrency_limit = 1
maildrop_destination_recipient_limit = 1
message_size_limit = 41943040
smtpd_recipient_limit = 10
bounce_queue_lifetime = 12h
maximal_queue_lifetime = 24h

smtpd_delay_reject = yes
smtpd_helo_required = yes
strict_rfc821_envelopes = yes

编辑/etc/local/etc/postfix/mysql-access.cf:

# ee /usr/local/etc/postfix/mysql-access.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
query = select access from tmail_access where source = '%s'

编辑/usr/local/etc/postfix/mysql-alias.cf:

# ee /usr/local/etc/postfix/mysql-alias.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_virtual
query = select alias from tmail_users where email = '%s'

编辑/usr/local/etc/postfix/mysql-autobbc-in.cf:

# ee /usr/local/etc/postfix/mysql-autobbc-in.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
query = select autobbc from tmail_autobbc where email = '%s' AND come='1'

编辑/usr/local/etc/postfix/mysql-autobbc-out.cf:

# ee /usr/local/etc/postfix/mysql-autobbc-out.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
query = select autobbc from tmail_autobbc where email = '%s' AND out='1'

编辑/usr/local/etc/postfix/mysql-mydest.cf:

# ee /usr/local/etc/postfix/mysql-mydest.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_domaininfo
query = select domain from tmail_domaininfo where domain = '%s' AND yesno = '1'

编辑/usr/local/etc/postfix/mysql-transport.cf:

# ee /usr/local/etc/postfix/mysql-transport.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_domaininfo
query = select transport from tmail_domaininfo where domain = '%s'

编辑/usr/local/etc/postfix/mysql-virtual-gid.cf:

# ee /usr/local/etc/postfix/mysql-virtual-gid.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_users
query = select gid from tmail_users where email = '%s'

编辑/usr/local/etc/postfix/mysql-virtual-uid.cf:

# ee /usr/local/etc/postfix/mysql-virtual-uid.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_users
query = select uid from tmail_users where email = '%s'

编辑/usr/local/etc/postfix/mysql-virtual-maps.cf:

# ee /usr/local/etc/postfix/mysql-virtual-maps.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_users
query = select maildir from tmail_users where email = '%s'

编辑/usr/local/etc/postfix/mysql-virtual-quota.cf:

# ee /usr/local/etc/postfix/mysql-virtual-quota.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_users
query = select quota from tmail_users where email = '%s'

编辑/usr/local/etc/postfix/mysql-virtual.cf:

# ee /usr/local/etc/postfix/mysql-virtual.cf

添加:

hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = tmail_virtual
query = select destination from tmail_virtual where email = '%s'

22、配置Courier-imap

方法:打开文件,利用查找功能修改

修改Courier相关设置,/usr/local/etc/courier-imap/imapd:

IMAP_CAPABILITY="IMAP4rev1 CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA"

修改/usr/local/etc/courier-imap/pop3d:

POP3AUTH="LOGIN CRAM-MD5 CRAM-SHA1"

修改/usr/local/etc/authlib/authmysqlrc:

MYSQL_SERVER         localhost
MYSQL_USERNAME       postfix
MYSQL_PASSWORD       postfix
MYSQL_PORT         0
MYSQL_OPT           0
MYSQL_DATABASE       postfix
MYSQL_USER_TABLE     tmail_users
MYSQL_CRYPT_PWFIELD   crypt
#MYSQL_CLEAR_PWFIELD   clear
MYSQL_UID_FIELD       uid
MYSQL_GID_FIELD       gid
MYSQL_LOGIN_FIELD     email
MYSQL_HOME_FIELD     homedir
MYSQL_NAME_FIELD     realname
MYSQL_MAILDIR_FIELD   maildir
MYSQL_QUOTA_FIELD     quota
MYSQL_AUXOPTIONS_FIELD CONCAT("disableimap=",disableimap,",disablepop3=",disablepop3,",disablewebmail=",disablewebmail,",sharedgroup=",sharedgroup)
MYSQL_WHERE_CLAUSE     access='y'

带下划线的是一行,注意不要分成两行,键和值之间用tab键来跳格

编辑/usr/local/etc/authlib/authdaemonrc:

authmodulelist="authmysql"
authmodulelistorig="authmysql"
version="authdaemond.mysql"
daemons=5
authdaemonvar=/var/run/authdaemond
subsystem=mail
DEBUG_LOGIN=0
DEFAULTOPTIONS="wbnodsn=1"

23、安装Tmail管理工具webadmin

更改httpd.conf中的Group www、User www修改为:Group vmail、User vmail

然后把此邮件存放根目录(这里是/mail)的所有权改成vmail,否则后面不能正常添加域名(或域名添加后不能创建用户而且也不能删除此域名)这样做:

# chown -R vmail:vmail /mail
# chmod -R 705 /mail

更改php.ini中的output_buffering = Off为output_buffering = On

上传webadmin到网站目录后修改config/config.inc.php中的:

define(MAILDIR,"/mail");        //邮件存放根目录
define(MISC, ".misc");
define(MODE,0700);
$PageSize = 15;                    //用户列表和域名列表每一页显示多少行
$host = "localhost";                //数据库主机名
$user = "postfix";                    //数据库用户名
$dbname = "postfix";                    //数据库名称
$password = "postfix";                //数据库密码

可查看一下main.cf中的邮件存放根目录设在哪里,这里也设置同样的目录

设置好后,管理员帐号登陆你的webadmin(要注意的是,那个验证码中的字母一律小写),添加一个域名,比如test.com,添加一个用户,比如test

你可能感兴趣的:(个人收录)