Tmail邮件系统安装手册 V2.0版本 1、系统环境 centos6.0以上,最小化安装(64位系统) 2、部署 1、删除自带的postfix、mysql、httpd # rpm -qa|grep postfix|xargs rpm -e --nodeps # rpm -qa|grep mysql|xargs rpm -e --nodeps 2、下载tmail安装包 wget http://60.173.10.106:88/tmail_setup.tar.bz2 3、安装 tar jxvf tmail_setup.tar.bz2 cd tmal_setup ./install.sh 看到这句话,说明安装成功了。 Tmail System Installed Succesfully! ^_^ 4、启动邮件系统重启系统即可 5、访问邮件系统 1、邮件系统后台 https://192.168.201.54 默认用户名:admin 默认密码:hing123 选择:管理员登录后台管理系统 2、邮件系统前台 http://192.168.201.54:88 输入:用户邮件地址和密码登录前台 3、邮件系统数据库 http://192.168.201.54:88/dbadmin/ 默认用户名:root 默认密码:tmail 3、常见故障 1、启动postfix故障 [root@test tmail]# /tmail/postfix/sbin/postfix start postsuper: fatal: scan_dir_push: open directory defer: Permission denied postfix/postfix-script: fatal: Postfix integrity check failed! 解决: [root@test tmail]# chown postfix:root /tmail/postfix/spool/ -R [root@test tmail]# chown postfix:postdrop /tmail/postfix/spool/maildrop/ -R [root@test tmail]# chown postfix:postdrop /tmail/postfix/spool/public/ -R [root@test tmail]# chmod g+s /tmail/postfix/sbin/postdrop [root@test tmail]# chmod g+s /tmail/postfix/sbin/postqueue [root@test tmail]# chown postfix.root /var/lib/postfix/ -R 启动postfix: [root@test tmail]# /tmail/postfix/sbin/postfix start postfix/postfix-script: starting the Postfix mail system 2、启动spamd故障 [root@test tmail]# /tmail/spamd/bin/spamd May 17 04:55:33.618 [29729] warn: netset: cannot include 127.0.0.1/32 as it has already been included May 17 04:55:35.329 [29729] info: spamd: server started on port 783/tcp (running version 3.3.2) May 17 04:55:35.329 [29729] info: spamd: server pid: 29729 May 17 04:55:35.332 [29729] info: spamd: server successfully spawned child process, pid 29731 May 17 04:55:35.350 [29729] info: spamd: server successfully spawned child process, pid 29732 May 17 04:55:35.354 [29729] info: prefork: child states: II May 17 05:02:30.710 [29731] info: spamd: connection from localhost [127.0.0.1] at port 55793 May 17 05:02:32.899 [29731] warn: spamd: bad protocol: header error: (closed before headers) May 17 05:02:42.161 [29729] info: prefork: child states: II 解决: [root@test tmail]# vi /tmail/spamd/etc/mail/spamassassin/local.cf #--trusted_networks_start-- #trusted_networks 127.0.0.1 //注释掉解决: warn: spamd: bad protocol: header error: (closed before headers) 域名问题 vi /etc/hosts XX.XX.XX.XX mail.XXX.com 4、postfix配置文件 1、vi /tmail/postfix/etc/main.cf #--system_default_process_limit_start-- default_process_limit = 50 #--system_default_process_limit_end-- #--system_default_destination_recipient_limit_start-- #如果一封信的收信人超过50个,postfix会自动将此信复制成很多份,以50人为单位,分批寄送 default_destination_recipient_limit = 50 #--system_default_destination_recipient_limit_end-- #--system_smtpd_error_sleep_time_start-- #当客户端引发错误时,postfix的初始等待时间。当错误次数超过smtpd_soft_error_limit的限制时,postfix在每次错误之后,都会延长5秒等待时间 smtpd_error_sleep_time = 5s #--system_smtpd_error_sleep_time_end-- #--system_smtpd_soft_error_limit_start-- #客户端在发生10次错误之后,postfix才开始执行再出现错误就延迟5秒的操作 smtpd_soft_error_limit = 10 #--system_smtpd_soft_error_limit_end-- #--system_smtp_hard_error_limit_start-- #SMTP服务所允许的硬错误次数。这个参数对于防止恶意攻击非常有效 smtp_hard_error_limit = 100 #--system_smtp_hard_error_limit_end-- #--system_strict_rfc821_envelopes_start-- #严格使用rfc821 strict_rfc821_envelopes = yes #--system_strict_rfc821_envelopes_end-- #--set_relayhost_start-- #relayhost = [61.139.2.69] #--set_relayhost_end-- #--system_domain_start-- #设置邮件服务器域名 myhostname = mail.XXX.com #--system_domain_end-- mydestination = localhost smtp_helo_name = $myhostname local_transport = maildrop virtual_transport = maildrop mailbox_transport = maildrop local_destination_concurrency_limit = 1 maildrop_destination_recipient_limit = 1 #--system_messages_size_limit_start-- #邮件附件大小50M message_size_limit = 52428800 #--system_messages_size_limit_end-- #让虚拟域,虚拟邮箱别名等读取mysql virtual_mailbox_base = / recipient_bcc_maps = mysql:/tmail/postfix/etc/mysql/recipient_bcc_map.cf sender_bcc_maps = mysql:/tmail/postfix/etc/mysql/sender_bcc_maps.cf virtual_mailbox_domains = mysql:/tmail/postfix/etc/mysql/virtual_mailbox_domains.cf #virtual_transport_maps = maildrop virtual_mailbox_maps = mysql:/tmail/postfix/etc/mysql/virtual_mailbox_maps.cf virtual_uid_maps = mysql:/tmail/postfix/etc/mysql/virtual_uid_maps.cf virtual_gid_maps = mysql:/tmail/postfix/etc/mysql/virtual_gid_maps.cf virtual_alias_maps = mysql:/tmail/postfix/etc/mysql/virtual_alias_maps.cf,mysql:/tmail/postfix/etc/mysql/tmail_group.cf virtual_alias_domains = $virtual_alias_maps relay_domains = mysql:/tmail/postfix/etc/mysql/relay_domains.cf #local_transport = virtual local_recipient_maps = $virtual_mailbox_maps broken_sasl_auth_clients = yes smtpd_sender_login_maps = mysql:/tmail/postfix/etc/mysql/smtp_login.cf smtpd_reject_unlisted_sender = yes #--restrict_start-- #smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10032 permit #--restrict_end-- smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, permit_tls_clientcerts, reject_unknown_sender_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_pipelining, reject_unauth_destination, # reject_unlisted_recipient, #--enable_rbl_client_start-- reject_rbl_client zen.spamhaus.org, reject_rbl_client cbl.abuseat.org, reject_rbl_client bl.spamcop.net, #--enable_rbl_client_end-- #--enable_policyd_start-- # check_policy_service inet:127.0.0.1:10031 #--enable_policyd_end-- #使用dovecot(生成的socket文件)来做smtpd的认证, 并设置允许本地用户和通过认证的用户使用smtpd(发邮件) smtpd_sasl_authenticated_header = yes //禁止匿名用户登录 smtpd_sasl_security_options = noanonymous smtpd_sasl_type = dovecot smtpd_sasl_path = /tmail/postfix/spool/private/auth #--disbale_lookup_start-- smtpd_peername_lookup = no #--disable_lookup_end-- #smtpd_delay_reject = yes smtpd_proxy_timeout = 180s #--helo_require_start-- smtpd_helo_required = yes #--helo_require_end-- #--disable_vrfy_start-- disable_vrfy_command=yes #--disable_vrfy_end-- #--enable_domainkey_start-- smtpd_milters = inet:localhost:8891 non_smtpd_milters = inet:localhost:8891 #--enable_domainkey_end-- #--start tls set-- #让smtp支持加密 smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_cert_file = /tmail/postfix/tls/cert.pem smtpd_tls_key_file = /tmail/postfix/tls/privkey.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom #--end tls set-- 2、启动postfix 启动: /tmail/postfix/sbin/postfix start 停止: /tmail/postfix/sbin/postfix stop 重新加载: /tmail/postfix/sbin/postfix reload 5、dovecot配置文件 1、dovecot支持的协议 vi /tmail/dovecot/etc/dovecot/dovecot.conf ## Dovecot configuration file # Protocols we want to be serving. #支持imap、pop3、lmtp协议 protocols = imap pop3 lmtp instance_name = dovecot 2、让dovecot支持mysql中的虚拟用户 1、 vi /tmail/dovecot/etc/dovecot/conf.d/10-auth.conf #取消该行注释 !include auth-sql.conf.ext 2、 vi /tmail/dovecot/etc/dovecot/dovecot-sql.conf.ext driver = mysql connect = host=localhost dbname=tmail user=tmail password=tmail default_pass_scheme = CRYPT password_query = SELECT email, domain, password FROM tmail_mailbox WHERE email = '%u' AND active = '1' userid = '%u' user_query = SELECT homedir AS home, uid, gid FROM tmail_mailbox where email = '%u' AND active = '1' 3、dovecot指定邮件存放目录 vi /tmail/dovecot/etc/dovecot/conf.d/10-mail.conf mail_location = maildir:%h/Maildir 6、杀毒软件Clamav 1、启动杀毒软件 /tmail/clamav/sbin/clamd 2、升级病毒库 /tmail/clamav/bin/freshclam 采用crontab设置定时升级病毒库 7、垃圾邮件过滤SpamAssassin 1、启动spamd /tmail/spamd/bin/spamd -u spamd -d -c -m5 -H -r /var/run/spamd.pid 2、设置参数通过登录后台,设置SpamAssassin 包括:(1)、对识别出来的垃圾邮件附加到主题的字符:如”垃圾“或“spam” (2)、是否在邮件内容中详细过滤信息(3)、安全网络,对安全网络发来的邮件不进行过滤(4)、设置过滤分数,高于此处设置的分数即为垃圾邮件(5)、是否使用贝叶斯算法(6)、是否开启贝叶斯自动学习 8、web程序使用nginx+php组合 1、web管理 1、启动web程序 /tmail/httpd/sbin/nginx 2、重新启动 kill -hup `cat /tmail/httpd/logs/nginx.pid` 2、php管理 1、启动php /tmail/httpd/php/sbin/php-fpm start 2、重新启动 /tmail/httpd/php/sbin/php-fpm reload 9、数据库 1、mysql启动 /tmail/mysql/support-files/mysql.server start 2、mysql管理默认root密码:tmail 可以通过phpmyadmin管理