标签:postfix
系统环境
CENTOS6.2 X86-64 并已经使用yum安装配置好LNMP环境
以下是安装所使用的部分软件包
shell>cd /usr/local/src
shell>wget http://jaist.dl.sourceforge.net/project/courier/imap/4.16.0/courier-imap-4.16.0.tar.bz2
shell>wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.11.4.tar.gz
shell>wget http://cznic.dl.sourceforge.net/project/courier/authlib/0.66.1/courier-authlib-0.66.1.tar.bz2
shell>wget ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz
shell>wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.11-patch04.gz
shell>wget http://cznic.dl.sourceforge.net/project/courier/courier-unicode/1.1/courier-unicode-1.1.tar.bz2
shell>wget http://jaist.dl.sourceforge.net/project/courier/maildrop/2.8.1/maildrop-2.8.1.tar.bz2
shell>wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.bz2
shell>wget ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module/DBD/DBD-mysql-4.031.tar.gz
shell>wget ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module/DBI/DBI-1.633.tar.gz
shell>wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.77.tar.gz
shell>wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.25.tar.gz
shell>wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.86.tar.gz
shell>wget http://www.cpan.org/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz
shell>wget http://www.cpan.org/authors/id/M/MG/MGRABNAR/File-Tail-1.0.tar.gz
shell>wget http://jaist.dl.sourceforge.net/project/clamav/clamav/0.98.6/clamav-0.98.6.tar.gz
shell>wget http://www.ijs.si/software/amavisd/amavisd-new-2.10.1.tar.xz
shell>wget http://www.cpan.org/authors/id/J/JM/JMEHNLE/mail-spf/Mail-SPF-v2.9.0.tar.gz
安装前准备工作
shell>yum -y groupinstall "Development tools"
shell>yum install libtool #安装courier-authlib须要
shell>yum install libtool-ltdl-devel #安装courier-authlib须要
shell>yum install expect #安装courier-authlib须要
shell>yum install gdbm-devel
shell>yum install libidn-devel
shell>yum install mysql-devel
shell>yum -y install db4-devel
创建组
shell>groupadd postfix -g 1000
shell>groupadd postdrop -g 1002
shell>useradd postfix -u 1000 -g postfix -G postdrop
shell>groupadd vmail -g 1001
shell>useradd vmail -u 1001 -g 1001 -M -s /bin/false
配置配置Nginx支持FCGI
shell>yum install perl-ExtUtils-Embed
shell>yum install perl-CGI
shell>cd /usr/local/src/
shell>tar -zxvf FCGI-0.77.tar.gz
shell>cd FCGI-0.77
shell>perl Makefile.PL
shell>make && make install
shell>cd ..
shell>tar -zxvf FCGI-ProcManager-0.25.tar.gz
shell>cd FCGI-ProcManager-0.25
shell>perl Makefile.PL
shell>make && make install
shell>cd ..
shell>tar zxvf IO-All-0.86.tar.gz
shell>cd IO-All-0.86
shell>perl Makefile.PL
shell>make && make install
shell>tar -zxvf Unix-Syslog-1.1.tar.gz
shell>cd Unix-Syslog-1.1
shell>perl Makefile.PL
shell>make && make install
shell>cd ..
shell>tar -zxvf DBD-mysql-4.031.tar.gz
shell>cd DBD-mysql-4.031
shell>perl Makefile.PL
shell>make && make install
shell>cd ..
shell>tar -zxvf DBI-1.633.tar.gz
shell>cd DBI-1.633
shell>perl Makefile.PL
shell>make && make install
卸载系统自带的POSTFIX
shell>rpm -qa |grep postfix
shell>groupadd -g 1000 postfix
shell>useradd -g postfix -u 1000 postfix -s /sbin/nologin
shell>groupadd -g 1002 postdrop
安装courier-authlib
shell>cd /usr/local/src/
shell>tar -jxvf courier-authlib-0.66.1.tar.bz2
shell>cd courier-authlib-0.66.1
shell>./configure --prefix=/usr/local/courier-authlib --with-mailuser=vmail --with-mailgroup=vmail --without-stdheaderdir --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authpgsql --with-authmysql --with-redhat CFLAGS="-march=x86-64 -O2 -fexpensive-optimizations" CXXFLAGS="-march=x86-64 -O2 -fexpensive-optimizations"
shell>make
shell>make install
shell>make install-configure
shell>cd /usr/local/courier-authlib/etc/authlib/
shell>cp authdaemonrc authdaemonrc.back
shell>vi authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
DEBUG_LOGIN=2
修改上面3项,其他的项保持不变。这个修改前2行表示用mysql认证模块;把DEBUG_LOGIN的值有默认的“0”改成“2”的用意是运行postfix时有更多的信息输出,通过生成的日志以帮助排错。
shell>cp authmysqlrc authmysqlrc.back
shell>vi authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_DATABASE extmail
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_PORT 3306
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password //这里需要注意
#MYSQL_CLEAR_PWFIELD password
DEFAULT_DOMAIN mail.test.com
MYSQL_UID_FIELD ‘1001’
MYSQL_GID_FIELD ‘1001’
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD ‘/var/mailbox/‘
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD concat(quota,‘S‘)
MYSQL_WHERE_CLAUSE active=‘1‘
shell> ln -s /usr/local/courier-authlib/include/* /usr/include/
shell>cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod +x /etc/init.d/courier-authlib
chkconfig --add courier-authlib
chkconfig courier-authlib on
service courier-authlib start
安装cyrus-sasl
先卸载系统自带的cyrus-sasl
shell>rpm -e cyrus-sasl
shell>rpm -e --nodeps cyrus-sasl-lib
shell>cd /usr/local/src/
shell>tar -zxvf cyrus-sasl-2.1.26.tar.gz
shell>cd cyrus-sasl-2.1.26
shell>./configure --prefix=/usr/local/sasl2 --disable-sample --disable-digest --disable-gssapi --disable-anon --enable-plain --enable-login --enable-sql --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket
shell>make
shell>make install
shell>ln -s /usr/local/sasl2/lib/sasl2 /usr/lib/
shell>ln -s /usr/local/sasl2/lib/sasl2 /usr/lib64/
shell>vi /etc/ld.so.conf
/usr/local/sasl2/lib/
/usr/local/sasl2/lib/sasl2
shell>ldconfig -v
shell>vi /usr/local/sasl2/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
mech_list: PLAIN LOGIN
log_level: 3
authdaemond_path: /usr/local/courier-authlib/var/spool/authdaemon/socket
shell>chmod +x -R /usr/local/courier-authlib/var/spool/authdaemon/
shell>mkdir -pv /var/state/saslauthd #创建运行时须要的目录
shell>/usr/local/sasl2/sbin/saslauthd -v #查看版本
shell>/usr/local/sasl2/sbin/saslauthd -a shadow pam -d #测试,正常的话不会报错,如果没有报错.crtl+c结束掉进程
shell>/usr/local/sasl2/sbin/saslauthd -a shadow pam
shell>/usr/local/sasl2/sbin/testsaslauthd -u root -p 123456 #正常显示0: OK "Success"表示成功(此处输入的是系统登录账号root 的密码,不是指的MySQL账号密码。否则会提示:
0: NO "authentication failed",同时,注意这里测试不用开启authdaemond(authlib)
shell>echo "/usr/local/sasl2/sbin/saslauthd -a shadow pam" >>/etc/rc.local
下载安装相同版本的VDA补丁,使postfix支持磁盘限额,如果未安装该补丁,POSTFIX配置磁盘限额后启动POSTFIX会报错
shell>tar -zxvf postfix-2.11.4.tar.gz
shell>wget http://vda.sourceforge.net/VDA/postfix-vda-v13-2.11.4.patch
shell>patch -p1 <postfix-vda-v13-2.11.4.patch
安装postfix
shell>cd postfix-2.11.4
shell>mkdir /var/mailbox
shell>chown vmail:vmail /var/mailbox/
shell>make Makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl‘ ‘AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2‘
shell>make
shell>make install #默认回车完成安装
shell>mv /etc/aliases /etc/aliases.old
shell>ln -s /etc/postfix/aliases /etc/aliases
shell>/usr/bin/newaliases #生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低
shell>/usr/sbin/postconf -a #正常显示 cyrus dovecot
shell>/usr/sbin/postconf -m |grep mysql #正常显示 mysql
安装IMAP,须要先安装courier-unicode,不然会报错
shell>tar -jxvf courier-unicode-1.1.tar.bz2
shell>cd courier-unicode-1.1
shell>./configure
shell>make
shell>make install
安装courier-imap
shell>tar -jxvf courier-imap-4.16.0.tar.bz2
shell>cd courier-imap-4.16.0
shell>./configure --prefix=/usr/local/courier-imap --with-redhat --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030 --disable-root-check --with-trashquota --with-dirsync --with-authmysql --with-authmysql=yes --without-ipv6 CPPFLAGS=‘-I/usr/local/courier-authlib/include‘ COURIERAUTHCONFIG=‘/usr/local/courier-authlib/bin/courierauthconfig‘
shell>make
shell>make install
shell>make install-configure
shell>vi /usr/local/courier-imap/etc/pop3d
POP3DSTART=YES
MAILDIRPATH=/var/mailbox
shell>vi /usr/local/courier-imap/etc/imapd
IMAPDSTART=YES
MAILDIRPATH=/var/mailbox
shell>cp /usr/local/src/courier-imap-4.16.0/packaging/systemd/courier-imap.sysvinit /etc/rc.d/init.d/imapd
shell>chmod +x /etc/rc.d/init.d/imapd
shell>chkconfig --add imapd
shell>chkconfig imapd on
shell>cd /usr/local/courier-imap/share
shell>./mkdhparams
shell>service imapd start
shell>netstat -tnl |egrep "110|143"
安装maildrop
shell>cp /lib64/libpcre.so.0 /lib64/libpcre.so.0-old
shell>rpm -e --nodeps pcre
shell>tar -jxvf pcre-8.35.tar.bz2
shell>cd pcre-8.35
shell>./configure
shell>make
shell>make install
shell>ln -s /usr/local/courier/bin/courierauthconfig /usr/bin/courierauthconfig #这条命令很重要,没有正常执行的话下面测试的时候Courier Authentication不会出现
shell>tar -jxvf maildrop-2.8.1.tar.bz2
shell>cd maildrop-2.8.1
shell>./configure --enable-sendmail=/usr/sbin/sendmail --enable-trusted-users=‘root vmail‘ --enable-syslog=1 --enable-maildirquota --enable-maildrop-uid=1001 --enable-maildrop-gid=1001 --with-trashquota --with-dirsync
shell>make
shell>make install
shell>echo "/usr/local/lib" >>/etc/ld.so.conf
shell>ldconfig -v
shell>maildrop -v
maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.
GDBM extensions enabled.
Courier Authentication Library extension enabled. #这行重要,没有的话要查一下原因
Maildir quota extension enabled.
This program is distributed under the terms of the GNU General Public
License. See COPYING for additional information.
shell>vi /etc/maildroprc
logfile "/var/log/maildrop.log"
to "$HOME/Maildir"
shell>touch /var/log/maildrop.log
shell>chown vmail:vmail /var/log/maildrop.log
安装配置extmail、extman
shell>mkdir /var/www/extsuite
shell>mount -o username=administrator,password=密码 //192.168.1.103/download /mnt/
shell>cp /mnt/extma* .
shell>tar -zxvf extmail-1.2.tar.gz -C /var/www/extsuite
shell>cd /var/www/extsuite/
shell>mv extmail-1.2/ extmail
shell>cp extsuite/extmail/webmail.cf.default webmail.cf
shell>chown -R vmail:vmail /var/www/extsuite/extmail/
shell>chmow +x R /var/www/extsuite/extmail/cgi
shell>cp nginx.conf nginx.conf-2015-03-26
shell>vi nginx.conf
user vmail vmail;
worker_processes 8;
#error_log /usr/local/nginx/logs/nginx_error.log crit;
error_log /usr/local/nginx/logs/nginx_error.log info;
pid /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
修改NGINX以及php-fpm所属用户及组为vmail,并修改相应文件属主,php-fpm配置文件www.conf,否则NGINX无法启动
shell>find / -gid 498 -exec chown :vmail {} \; #将所有属组为NGINX的文件的属组修改为vmail
shell>find / -uid 498 -exec chown vmail {} \; #将所有属主为NGINX的文件的属主修改为vmail
shell>cd conf.d/
shell>vi extmail.conf
server
{
listen 80;
server_name mail.test.com;
index index.html index.htm index.php index.cgi;
root /var/www/extsuite/extmail/html/;
location /extmail/cgi/ {
fastcgi_pass 127.0.0.1:12009;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
include fastcgi.conf;
}
location ^~ /extmail/ {
alias /var/www/extsuite/extmail/html/;
}
location /extman/cgi/ {
fastcgi_pass 127.0.0.1:12009;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extman/cgi/$fastcgi_script_name;
include fastcgi.conf;
}
location ^~ /extman/ {
alias /var/www/extsuite/extman/html/;
}
location ^~ /status {
stub_status on;
access_log off;
allow 192.168.0.0/24;
#deny all;
}
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:12009;
fastcgi_index index.cgi;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
shell>vi /var/www/extsuite/extmail/dispatch-init
MAXFORK=20
MAXREQS=500
TIMEOUT=300
PORT=12009 #端口号与extmail.conf文件保持一致,
SU_UID=vmail
SU_GID=vmail
shell>tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite
shell>mv extman-1.1/ extman
shell>chown -R vmail:vmail /var/www/extsuite/extman/
shell>mkdir -pv /tmp/extman
shell>chown -R vmail:vmail /tmp/extman/
shell>cd /var/www/extsuite/extman/docs/
shell>cp init.sql init.sql.back
shell>vi init.sql
更改init.sql中extmail.org的名称为自已域名
shell>vi extmail.sql
/*
ExtMail - OSS
License: GPL v2
This is the MySQL database structure for ExtMail System, derive from
Postfixadmin ( http://high5.net/howto/ ) project, and modify to meet
our need, it is compatible with PostfixAdmin MySQL structure and have
some extmail specific attributes and structure
ExtMail have an alternative solution on openLDAP, please check the
extmail.schema (V3) for detail.
You can create the database from the shell with:
mysql -u root [-p] < extmail.sql
*/
/*
Initialize mysql
*/
USE mysql;
/* readonly user & password */
/* clean user if exists */
delete FROM user where User in (‘extmail‘,‘webman‘);
delete FROM db where User in (‘extmail‘,‘webman‘);
INSERT INTO user (Host, User, Password) VALUES (‘localhost‘,‘extmail‘,password(‘extmail‘));
INSERT INTO db (Host, Db, User, Select_priv) VALUES (‘localhost‘,‘extmail‘,‘extmail‘,‘Y‘);
/* extman read/write user & password */
INSERT INTO user (Host, User, Password) VALUES (‘localhost‘,‘webman‘,password(‘webman‘));
INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES (‘localhost‘, ‘extmail‘, ‘webman‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘);
FLUSH PRIVILEGES;
/* readonly user */
GRANT USAGE ON extmail.* TO extmail@localhost;
GRANT SELECT, UPDATE ON extmail.* TO extmail@localhost;
/* read/write user */
GRANT USAGE ON extmail.* TO webman@localhost;
GRANT SELECT, INSERT, DELETE, UPDATE ON extmail.* TO webman@localhost;
CREATE DATABASE extmail;
USE extmail;
/* Table structure for table manager */
CREATE TABLE manager (
username varchar(255) NOT NULL default ‘‘,
password varchar(255) NOT NULL default ‘‘,
type varchar(64) NOT NULL default ‘postmaster‘,
uid varchar(255) NOT NULL default ‘‘,
name varchar(255) NOT NULL default ‘‘,
question text NOT NULL default ‘‘,
answer text NOT NULL default ‘‘,
disablepwdchange smallint(1),
createdate datetime NOT NULL default ‘0000-00-00 00:00:00‘,
expiredate DATE NOT NULL default ‘0000-00-00‘,
active tinyint(1) NOT NULL default ‘1‘,
PRIMARY KEY (username)
) ENGINE=MyISAM COMMENT=‘Ext/Webman - Admin Accounts‘;
CREATE TABLE alias (
address varchar(255) NOT NULL default ‘‘,
goto text NOT NULL,
domain varchar(255) NOT NULL default ‘‘,
createdate datetime NOT NULL default ‘0000-00-00 00:00:00‘,
active tinyint(1) NOT NULL default ‘1‘,
PRIMARY KEY (address)
) ENGINE=MyISAM COMMENT=‘ExtMail - Virtual Aliases‘;
CREATE TABLE domain (
domain varchar(255) NOT NULL default ‘‘,
description varchar(255) NOT NULL default ‘‘,
hashdirpath varchar(255) NOT NULL default ‘‘,
maxalias int(10) NOT NULL default ‘0‘,
maxusers int(10) NOT NULL default ‘0‘,
maxquota varchar(16) NOT NULL default ‘0‘,
maxnetdiskquota varchar(16) NOT NULL default ‘0‘,
transport varchar(255) default NULL,
can_signup tinyint(1) NOT NULL default ‘0‘,
default_quota varchar(255) default NULL,
default_netdiskquota varchar(255) default NULL,
default_expire varchar(12) default NULL,
disablesmtpd smallint(1),
disablesmtp smallint(1),
disablewebmail smallint(1),
disablenetdisk smallint(1),
disableimap smallint(1),
disablepop3 smallint(1),
createdate datetime NOT NULL default ‘0000-00-00 00:00:00‘,
expiredate DATE NOT NULL default ‘0000-00-00‘,
active tinyint(1) NOT NULL default ‘1‘,
PRIMARY KEY (domain)
) ENGINE=MyISAM COMMENT=‘ExtMail - Virtual Domains‘;
CREATE TABLE domain_manager (
username varchar(255) NOT NULL default ‘‘,
domain varchar(255) NOT NULL default ‘‘,
createdate datetime NOT NULL default ‘0000-00-00 00:00:00‘,
active tinyint(1) NOT NULL default ‘1‘,
KEY username (username)
) ENGINE=MyISAM COMMENT=‘Ext/Webman - Domain Admins‘;
CREATE TABLE mailbox (
username varchar(255) NOT NULL default ‘‘,
uid varchar(255) NOT NULL default ‘‘,
password varchar(255) NOT NULL default ‘‘,
clearpwd varchar(128) NOT NULL default ‘‘,
name varchar(255) NOT NULL default ‘‘,
mailhost varchar(255) NOT NULL default ‘‘,
maildir varchar(255) NOT NULL default ‘‘,
homedir varchar(255) NOT NULL default ‘‘,
quota varchar(16) NOT NULL default ‘0‘,
netdiskquota varchar(16) NOT NULL default ‘0‘,
domain varchar(255) NOT NULL default ‘‘,
uidnumber int(6) NOT NULL default ‘1000‘,
gidnumber int(6) NOT NULL default ‘1000‘,
createdate datetime NOT NULL default ‘0000-00-00 00:00:00‘,
expiredate DATE NOT NULL default ‘0000-00-00‘,
active smallint(1) NOT NULL default ‘1‘,
disablepwdchange smallint(1),
disablesmtpd smallint(1),
disablesmtp smallint(1),
disablewebmail smallint(1),
disablenetdisk smallint(1),
disableimap smallint(1),
disablepop3 smallint(1),
question text NOT NULL default ‘‘,
answer text NOT NULL default ‘‘,
PRIMARY KEY (username)
) ENGINE=MyISAM COMMENT=‘ExtMail - Virtual Mailboxes‘;
shell>mysql -u root -p <extmail.sql
shell>mysql -u root -p <init.sql
shell>vi extmail/webmail.cf
SYS_USER_LANG = en_US 改为SYS_USER_LANG = zh_CN
SYS_MAILDIR_BASE = /home/domains 右边改为 /var/mailbox
SYS_MYSQL_USER = db_user 右边改为extmail
SYS_MYSQL_PASS = db_pass 右边改为extmail
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
shell>cd ../../extman/
shell>cp webman.cf.default webman.cf
shell>vi webman.cf
SYS_MAILDIR_BASE = /home/domains 右边改为/var/mailbox
SYS_DEFAULT_UID = 1001
SYS_DEFAULT_GID = 1001
SYS_CAPTCHA_ON = 0 //关闭图形验证码
shell>/var/www/extsuite/extmail/dispatch-init start
shell>service nginx restart
配置postfix
shell> vi /etc/postfix/master.cf
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
shell> vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = njjnyy.cn
mydomain = njjnyy.cn
myorigin = $mydomain
inet_interfaces = all
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydestination =
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.0.0/24,127.0.0.0/8
relay_domains = $mydestination 无
alias_maps = $alias_database 无
defer_transports = 无
mail_spool_directory = /var/spool/mail 无
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/local/man
sample_directory = /etc/postfix
readme_directory = no
############################CYRUS-SASL########################
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
#smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
#############################SASL-END##############################
#############################Virtual Mailbox Settings################
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_alias_domains=
virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:1001 #vmail
virtual_gid_maps = static:1001 #vmai
virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
#################################Mailbox END###########################
#################################Quota Settings########################
message_size_limit = 200000000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.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
################################Quota END############################
################################Amavis Start##########################
content_filter=amavisfeed:[127.0.0.1]:10024
max_use=10
################################Amavis END###########################
测试邮件账号
shell>/usr/local/courier-authlib/sbin/authtest -s smtp lxb@njjnyy.cn l123456
正常显示如下:
Authentication succeeded.
Authenticated: lxb@njjnyy.cn (uid 1001, gid 1001)
Home Directory: /var/mailbox/njjnyy.cn/lxb
Maildir: /var/mailbox/njjnyy.cn/lxb/Maildir/
Quota: 5242880S
Encrypted Password: $1$Ynp2/b/r$5DHAdX18fsbJMR98CU.1o/
Cleartext Password: a123456
安装webmail图形化日志
shell>yum install rrdtool
shell>yum install rrdtool-perl
shell>yum install perl-Time-HiRes
shell>cd /usr/local/src/
shell>tar -zxvf File-Tail-1.0.tar.gz
shell>cd File-Tail-1.0
shell>perl Makefile.PL
shell>make && make install
shell>cp -r /var/www/extsuite/extman/addon/mailgraph_ext /usr/local/
shell>/var/www/extsuite/extman/daemon/cmdserver -d
shell>/usr/local/mailgraph_ext/mailgraph-init start
shell>echo "/var/www/extsuite/extman/daemon/cmdserver -d" >>/etc/rc.local
shell>echo "/usr/local/mailgraph_ext/mailgraph-init start">>/etc/rc.local
extmail登录界面修改
1 修改文件:/var/www/extsuite/extmail/html/default/index.html
设定默认域名
<TD><INPUT TYPE="text" class="input_n" NAME="domain" value="njjnyy.cn"></TD>
其中的domain和example.com随自己实际情况进行更改。
POP3和SMTP设置信息提示
POP3 <b>:</b>& nbsp;& nbsp;pop3.yourdomain.com<br />
SMTP <b>:</b>& nbsp;& nbsp;smtp.yourdomain.com<br />
技术支持和自愿捐助连接,用<!-- -->注释掉。
<div class=donate> <a href="http://www.extmail.org/support/<%LANG%>/index.html" target="_blank"> <b><%support_link%></b></a> | <img style="vertical-align: middle" src="/extmail/images/donate.png"> <a
2 修改文件:/var/www/extsuite/extmail/webmail.cf
去除免费注册
修改位置:SYS_SHOW_SIGNUP = 1
修改结果:SYS_SHOW_SIGNUP = 0
去掉网络磁盘功能
修改位置:SYS_NETDISK_ON = 1
修改结果:SYS_NETDISK_ON = 0
3 更换logo标志
修改文件:/var/www/extsuite/extmail/html/default/images/logo.gif
修改内容:替换成需要的Logo图片文件
4 修改文件:/var/www/extsuite/extmail/lang/zh_CN
修改位置:
%lang_login = (
meta_title => ‘欢迎使用ExtMail‘
修改位置:
%lang_login = (
intro2 => ‘<b>快速而可靠</b><br />引入索引缓存(Cache)技术和高效核心,WebMail操作疾步如飞‘,
intro3 => ‘<b>多语言同屏读写</b><br />全面支持UTF8,实现同屏读写多国语言,真正做到国际邮、无乱码‘,
intro4 => ‘<b>真正模板化设计</b><br />MVC设计+高速模板引擎,实现了内容数据完全分离,轻松修改模板‘,
intro5 => ‘<b>高性能I/O</b><br />;轻松应付>1GB邮箱/200M附件,远强于流行的各式php webmail‘,
修改位置:
%lang_login = (
wsplash => ‘快速可靠, 高性能I/O
开源MAIL开足马力迈进中...‘,
修改位置:
%lang_login = (
welcome_index => ‘欢迎使用ExtMail!‘
5 修改文件:/var/www/extsuite/extmail/html/default/TOP_BAN.html
注释掉
href="http://www.extmail.org/support/<%LANG%>/about.html"><%about%></a> | <a target=_blank href="http://www.extmail.org/support/<%LANG%>/help.html"><%help%></a></span>
6修改文件:/var/www/extsuite/extmail/html/default/BOTTOM.html
<div id="Bcr">Powered by <%VERSION%> 2006 ExtMail.Org Runtime: <%TIME%><br>
<%extmail_whatis%></div>
上面内容可以根据页面底部的显示信息对比修改。
7 修改文件:/var/www/extsuite/extmail/html/default/welcome.html
去掉项目新闻 注释掉下面内容
<div style="padding-left: 5px;padding-right:5px">
<div class="panelout" id="etnews_div">
<div class="paneltit"> ExtMail Project News</div>
<div class="panelin" id="etnews_container">
</div>
</div>
<script type="text/javascript">
etnews_init();
</script>
</div>
8 更换原天气预报代码
更换掉原来的这段代码
<TD width=230px valign=top style="">
<div class="panelout" id="coolweather_div">
<div class="paneltit"> <%weatherinfo%></div>
<div class="panelin" id="coolweather_container">
</div>
<script type="text/javascript">
coolweather_iconspath = ‘/extmail/plugins/coolweather/icons/‘;
coolweather_init();
</script>
</div>
</TD>
<TD width=10px></TD>
新的代码为
<TD width=230px valign=top style="">
<iframe src="http://www.thinkpage.cn/weather/weather.aspx?c=BU5CI&l=&p=CMA&a=1&u=C&s=1&m=1&x=1&d=3&fc=&bgc=&bc=" frameborder="0" scrolling="no" width="200" height="260" allowTransparency="true">
</iframe>
</TD>
<TD width=10px></TD>
安装CLAMAV杀毒软件
shell>adduser -s /bin/false -c "Amavis User" -d /var/amavis amavis
shell>useradd -s/bin/false -d /dev/null clamav
shell>cd /usr/local/src/
shell>tar zxvf clamav-0.98.6.tar.gz
shell>./configure --prefix=/usr/local/clamav --with-dbdir=/usr/local/share/clamav
shell>make
shell>make install
shell>cp clamd.conf.sample clamd.conf
shell>vi clamd.conf
LogFile /var/log/clamav/clamd.log
LogTime yes
LogFacility LOG_MAIL
LogSyslog yes
LogVerbose yes
PidFile /var/run/clamd.pid
DatabaseDirectory /usr/local/share/clamav
LocalSocket /tmp/clamd.socket
StreamMaxLength 100M
User amavis
ScanMail yes
ScanArchive yes
shell>sed -e ‘/^#/d‘ -e ‘/^$/d‘ clamd.conf #查看配置文件
shell>cp freshclam.conf.sample freshclam.conf
shell>vi freshclam.conf
DatabaseDirectory /usr/local/share/clamav
UpdateLogFile /var/log/clamav/freshclam.log
LogVerbose yes
LogSyslog yes
LogTime yes
PidFile /var/run/freshclam.pid
DatabaseOwner amavis
DatabaseMirror db.CN.clamav.net
DatabaseMirror database.clamav.net
Checks 12
shell>mkdir /usr/local/share/clamav
shell>mkdir /var/log/clamav
shell>chmod -R 744 /var/log/clamav
shell>chown -R amavis:amavis /var/log/clamav
shell>chown -R amavis.amavis /usr/local/share/clamav
shell>vi /etc/init.d/clamd
#! /bin/bash
#
# crond Start/Stop the clam antivirus daemon.
#
# chkconfig: 2345 90 60
# description: clamdis a standard UNIX program that scans for Viruses.
# processname: clamd
# config: /usr/local/clamav/etc/clamd.conf
# pidfile: /var/run/clamd.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
# See how we were called.
prog="clamd"
progdir="/usr/clamav/local/sbin"
# Source configuration
if [ -f /etc/sysconfig/$prog ] ; then
. /etc/sysconfig/$prog
fi
start() {
echo -n $"Starting $prog: "
daemon $progdir/$prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/run/clamd.pid
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamd.pid
return $RETVAL
}
rhstatus() {
status clamd
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading clam daemon configuration: "
killproc clamd -HUP
retval=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/clamd ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
exit 0
shell>chkconfig --add clamd
shell>chkconfig clamd on
shell>service clamd start
shell>/usr/local/clamav/bin/freshclam
安装amavisd-new amavisd-new是一个高性能、可靠的用于连接邮件传输代理和内容检查器之间的接口,例如邮件的病毒扫描、垃圾邮件过滤等等
查看已经安装的perl模块
shell>perldoc -t perllocal | grep "Module"
shell>yum install perl-YAML.noarch
shell>cd /usr/local/src
shell>tar zxvf Mail-SPF-v2.9.0.tar.gz
shell>cd Mail-SPF-v2.9.0
shell>perl Makefile.PL
shell>make && make install
shell>perl -MCPAN -e shell ## 在安装前确定你的系统语言不是UTF-8
cpan> install Archive::Tar
cpan> install Archive::Zip
cpan> install Compress::Zlib
cpan> install Convert::TNEF
cpan> install Convert::UUlib
cpan> install Convert::BinHex
cpan> install MIME::Base64
cpan> install MIME::Parser
cpan> install MIME::Tools
cpan> install Mail::Internet
cpan> install Net::Server
cpan> install Net::LibIDN
cpan> install Net::SMTP
cpan> install Digest::MD5
cpan> install IO::Stringy
cpan> install Time::HiRes
cpan> install Unix::Syslog
cpan> install BerkeleyDB
cpan> install Crypt::OpenSSL::RSA
cpan> install Digest::SHA1
cpan> install DBI
cpan> install DB_File
cpan> install Net::DNS
cpan> install Mail::DKIM::Verifier
cpan> install Mail::SpamAssassin
cpan> install IP::Country
cpan> install URI::_idna
cpan> install Net::IDN::Encode
cpan> install Net::Ident
cpan> install IO::Socket::INET6
cpan> install IO::Socket::SSL
cpan> install NetAddr::IP
cpan> install Net::DNS::Resolver::Programmable
cpan> install installed: Geo::IP
cpan> install Razor2::Client::Agent
cpan> install IO::Socket::IP
cpan> install Encode::Detect
cpan> install Net::Patricia
cpan> install LWP::UserAgent
cpan> install Mail::SPF::Query
cpan> install HTML::Parser
cpan> exit
shell>vi amavisd.sh
#!/bin/bash
tar Jxvf amavisd-new-2.10.1.tar.xz && cd amavisd*
mkdir -p /var/amavis/tmp /var/amavis/var /var/amavis/db /var/amavis/home
chown -R amavis:amavis /var/amavis
chmod -R 750 /var/amavis
cp amavisd /usr/local/sbin/
chown root /usr/local/sbin/amavisd
chmod 755 /usr/local/sbin/amavisd
cp amavisd.conf /etc/
chown root /etc/amavisd.conf
chmod 644 /etc/amavisd.conf
mkdir /var/virusmails
chown amavis:amavis /var/virusmails
chmod 750 /var/virusmails
cp amavisd_init.sh /etc/init.d/amavisd
chmod 744 /etc/init.d/amavisd
chkconfig --add amavisd
chkconfig amavisd on
shell>./amavisd.sh
vi /etc/amavisd.conf
$max_servers=8;
$daemon_user = ‘amavis‘;
$daemon_group = ‘amavis‘;
$mydomain = ‘njjnyy.cn‘;
$db_home = "$MYHOME/db";
$inet_socket_port = 10024;
$sa_tag_level_deflt = 5.0;
$sa_tag2_level_deflt = 6.2;
$sa_kill_level_deflt = $sa_tag2_level_deflt;
$virus_admin = "virusalert@$mydomain";
$sa_spam_subject_tag = ‘***SPAM*** ‘;
$forward_method = ‘smtp:127.0.0.1:10025‘;
$notify_method = $forward_method;
$final_virus_destiny = D_DISCARD;
$final_banned_destiny = D_DISCARD;
$final_spam_destiny = D_DISCARD;
[‘ClamAV-clamd‘,
\&ask_daemon, ["CONTSCAN {}\n", "/amd.socketmp/clamd.socket"],
qr/\bOK$/m, qr/\bFOUND$/m,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
自动更新spamassassin clamav
shell>rpm -ivh --nodeps cronie
shell>crontab -e
0 0 * * * /usr/local/bin/sa-update -D --nogpg
0 4 * * * /usr/local/clamav/bin/freshclam --quiet -l /var/log/clamav/freshclam.log
本文出自 “学习笔记” 博客,请务必保留此出处http://303188936.blog.51cto.com/2722929/1636754
Centos 6.2_X86_64 编译安装postfix+amavisd-new+clamav
标签:postfix
原文地址:http://303188936.blog.51cto.com/2722929/1636754