west open source technology center
chdir to /home/domains/test.com/test/Maildir/, Permissiondenied(如果遇到这样的问题,就是selinux没有关闭,关闭selinux或者安下面的更改)。
铃高手 hzqbbc 呀,
一语惊醒我了。
的确忘了修改 /etc/rc.d/rc.local
加入了后再次重启都没有问题了。
/usr/sbin/setsebool httpd_disable_trans=1
/usr/sbin/setsebool mysqld_disable_trans=1
/etc/init.d/mysqld restart
/etc/init.d/httpd restart
1.安装postfix解
Yuminstall postfix �Cy
/etc/init.d/postfixstart
Netstat�Cantlpe | grep 25
这样就可以给自己的主机发邮件了
Mailq 查看没有发出去的邮件队列
2 配置postfix的主配置文件
Vi /etc/postfix/main.cf更改如下:
myhostname =server90.example.com(主机名)
mydomain = example.com (主机域名)
inet_interfaces = all 监听的网络接口
inet_protocols = all 监听ipv4和ipv6
mydestination = $myhostname,( localhost.去掉)$mydomain,localhost
/etc/init.d/postfix restart 就可以发邮件了
3 配置虚拟用户
Postconf �Cd 列出所有虚拟配置
Postconf �Ce “virtual_alias_maps =hash:/etc/postfix/virtual”(hash哈希加密virtual 为虚拟用户所在文件)
Vi /etc/postfix/virtual 在最后一行增加
[email protected](真是的地址)[email protected](虚拟的地址)
postmap virtual 生成virtual.db文件。让postfix可读加密文件
/etc/init.d/postfix restart
postconf �Cd | grep generic
postconf �Ce “smtp_generic_manps” =hash:/etc/postfix/generic”
vi /etc/postconf/generic 在最后增加
[email protected](真实邮址) [email protected](假装的邮址)
postmap generic
/etc/init.d/postfix restart
3 用telnet 检验postfix是否可以发信
telnet 192.168.0.250 25
ehlo hello
mail from:[email protected]
rcpt to:[email protected]
data
as
as
quit
4 设置拒绝哪些用户和域可以收邮件
Postconf �Cd | grep client
Postconf �Ce “smtpd_client_restrictions =check_client_access hash:/etc/postfix/access”
Vi access最后增加一行
192.168.0.254 REJECT(拒绝这个域)
Postmap access (生成access.db文件)
/etc/init.d/postfix restart
5 拒绝哪些用户可以发邮件
Postconf �Cd | grep sender
Postconf �Ce “smtpd_sender_restrictions =check_sender_access hash:?etc/postfix/sender”
Vi /etc/postfix/sender更改如下:
[email protected] REJECT
postmap sender
/etc/init.d/postfix restart
6 设置哪些用户不可以收
Postconf �Cd |grep reci
Postconf �Ce “smtpd_recipient_restrictions =check_recipient_accesshash:/etc/postfix/recipient,permit_mynetworks,reject_unauth_destination”
Vi recipient 更改如下:
[email protected] REJECT
postmap recipient
/etc/init.d/postfix restart
7 设置收信
Yum install dovecot �Cy (安装豆腐块)
/etc/init.d/dovecot start
Chkconfig dovecot on
Netstat �Cantlpe | grep dovecot
Cd /etc/dovecot
Cd conf.d/
Vi dovecot.conf 打开加密验证就可以收信了
8 postfix和mysql一起用
Yum install mysql-server �Cy
/etc/init.d/mysqld start
装完可以直接用mysql 登录的
Show databases;(查看数据库)
Use mysql(切换数据库)
Show tables;(查看数据库中的表)
Select * from user ;查看数据表中的信息
Mysql_secure_installation 更改数据库的root的密码
Create database westos;创建数据库
Use westos;
Create table linux (username varchar(50)not null,password varchar(50) not null );
Desc linux;查看表结构
Insert into linux values (‘user1’,’passwd1’);给表中插入值
Select * from linux 查看表中数据
Update linux set password=password(‘paswd1’)where usernme=’user1’;
Delete from linux where username=’user2’;
Delete linux 删除所有表中的信息
Drop table linux;删除表
Drop database westos; 删除数据库
Grant all on westos.* to user1@localhostidentified by ‘lee’
忘记mysql的root密码
1 停止mysql 服务
/etc/init.d/mysqld stop
Mysqld_safe �Cskip-grant-tables&后台执行此命令
Mysql 直接进入mysql
Use mysql;
Show tables;
Update user set passeord(‘lee’) where user=’root’;
/etc/init.d/mysqld restart
Mysql �Curoot �Cplee就能进了
Mysqladmin �Curoot �Cplee password westos 改root的密码
安装phpMyAdmin
下载安装包
Tar jxf phpMyAdmin-….解压
Mv phpmyadmin-… phpadmin
安装支持php用行的软件
Yum install php httpd php-mysql �Cy
/etc/init.d/httpd start
Mv phpadmin /var/www/html
Cd /var/www/html/phpadmin
Cp �Cp config.sample.inc.php config.inc.php
Vi config.inc.php 更改如下
给 YOUMUSTFILEINTHIFORCOOKIEAUTH!*/ 前面的等号后面=’westos’加给westos 为密码
/etc/init.d/httpd restart
在浏览器输入192.168.0.250/phpadmin就可以用图形化工具管理数据库了
3 配置mysql和postfix可以使postfix使用mysql中的数据
1 删除postfix以前所有的配置最好的办法是 yum reinstall postfix �Cy
Cd /etc/postfix
在mysql 中建立一个postfix数据库建立一个mail表表中有4个字段 usernamepassword domain maildir 四个值分别为[email protected] user1westos.org westos.org/user1/maildir/(最后必须有反斜杠)
2 添加用户 useradd �Cg 800 vmail
Postconf �Cd
Postconf �Ce “virtual_mailbox_base =/home/vmail”
Postconf �Ce “virtual_uid_maps = static:800”
Postconf �Ce “virtual_uid_maps = static:800”
3给mysql建一个有权限的用户进入mysql
Use mysql
Grant all on postfix.all to postfix@’%’identified by ‘postfix’;
Postconf �Ce “virtual_alias_maps =mysql:/etc/postfix/mysql-alias.cf” 查找用户的
Postconf �Ce “virtual_mailbox_domain =mysql:/etc/postfix/mysql-domain.cf”查找域名的
Postconf �Ce “virtual_mailbox_maps =mysql:/etc//postfix/mysql-mailbox”查找邮件地址的
Cd /etc/postfix
Vi mysql-alias.cf 编写如下:
hosts = localhost
user = postfix(数据库中添加的用户)
password = postfix
dbname = postfix数据库名字
table = mail 表的名字
select_field = username
where_field = uername
vi mysql-domain 编写如下:
hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = mail
select_field = domain
where_field = domain
vi mysql-mailbox.cf 编写如下:
hosts = localhost
user = postfix
password = postfix
dbname = postfix
table = mail
select_file = maildir
where_field = username
/etc/init.d/postfix restart
检验
Postmap �Cq “[email protected]” mysql:/etc/postfix/mysql-alias.cf
Postmap �Cq “[email protected]”mysql:/etc/postfix/mysql-mailbox.cf
Postmap �Cq “westos”mysql:/etc/postfix/mysql-domain
给user1发一分邮件如果/home/mail/出现westos.org 则配置成功
Mail [email protected]
4 配置豆腐块让他可以收邮件配合mysql
Yum install dovecot dovecot-mysql
/etc/init.d/dovecot start
Cd /etc/dovecot/
Cd conf.d/
Vi 10-mail.conf更改如下:
Mail_location =maildir:/home/vmail/%d/%n/maildir
First_valid_uid = 800
Vi 10-auth.conf更改如下:
Auth_mechanisms = plain
去掉!includeauth-sql.conf.xt 打开sql验证
Cd /usr./share/doc/dovecot-2.0/example-config/
Cp dovecot-sql.conf.ext /etc/dovecot/
Cd /etc/dovecot/
Vim dovecot-sql.conf.ext更改如下:
Driver = mysql
Connect = host=localhost dbname=postfixuser=postfix password=postfix
Default_pass_scheme = plain
Password_query = \
Select username,domain,password \
From mail where username = ‘%u’ and domain= ‘%d’
/etc/init.d /dovecotrestart
验证
telnet 192.168.0.250 110
user [email protected]
pass user1
看能发过去不
5 postfix 版本升级
5.1postconf mail_version 查看当前系统postfix的版本
到postfix.org 下载最新的版本
Scp [email protected]:/var/ftp/pub/docs/postfix吧本机的postfix上传的254主机上
tar zxf postfix-2.10.2tar.gz解压最新版本
cd postfix
dig -t mx qq.com 查看qq.com的邮件主机 dig �Ct gmail.com
less INSTALL 查看安装说明
rpm �Cq postfix 查看postfix的版本
postconf -m 查看postconf 安装支持的服务
postconf �Cn 查看postfix的最新配置
inet_protocols=ipv4接听的ip类型
升级 postfix 必须安装make
yum install -y make
cd /README_FILES/
less MYSQL_README 查看MYSQL_README 安装说明
make �Cf Makefile.init makefiles
如果提示 Install the appropriate db*-devel package first
yum install db*-devel -y
如果提示 gcc :command not found
yum install -y gcc 安装gcc 编译器
makeupgrade 升级postfix
postconf -m 查看支持的服务此时不支持Mysql 要让postfix支持mysql 则要升级mysql
要升级mysql则要安装mysql的编译
yum install mysql-devel -y
rpm -ql mysql-devel
cd /usr/include/mysql/ 带.h的都为编译文件
cd /usr/lib64/mysql/ 带.so的文件
最好的办法是吧最新的postfix删除
make -f makefile.init makefiles \
> ‘CCARGS=-DHAS_MYSQL -I /usr/include/mysql’ \
> ‘AUXLIBS=-L /usr/lib64/mysql -lmysqlclient -lz -lm’
然后 make upgrade 升级
Postconf -m 查看支持的服务
/etc/init.d/postfix restart
Netstat -antlp | grep 25 (postfix接听25端口)
yum install -y mailx邮件发送
5.2 安装mysql
Mysqladmin -uroot �Cpwestos password 123
Mysqladmin �Curoot password westos
Yum install mysql-server mysql
flush privileges; 刷新数据库
mysqldump �Curoot �Cpwestos mysql > mysql.bak备份数据库
mysql �Curoot �Cpwestos westos < mysql.bak回复数据库
忘记mysql的root密码修改密码
Mysqld_safe --skip-grant-tables &后台运行
mysql 进入mysql然后更改mysql的root密码
/etc/init.d/mysqld restart
5.3.用phpMyAdmin 管理数据库
tar jxf phpMyAdmin….
Mv phpMyAdmin /var/www/html/
Cd /var/www/html/phpMyAdmin
Cp config.sample.inc.php config.inc.php
Vi config.inc.php 更改如下:
在 = ‘westos ’加好 YOUMUSTFILLIN THIS FOR COOKIE AUTH 就可以用phpMyAdmin管理mysql了
5.4 配置postfix使他可以使用数据库中的用户
Useradd �Cu 800 email
Postconf -d
Postconf -e virtual_mailbox_base=/home/email/
Postconf �Ce virtual_uid_maps=static:800
Postconf �Ce virtual_gid_maps=static:800
Cd /etc/popstfix/
Mysql �Cpwestos
Grant all on linux.* to email@localhostidentified by ‘westos’;user
Vi mysql:alias.cf 如下:
User = email
Password = email
Dbname = linux
Table = email
Select_field = username
Where_field = username
Vi mysql:domain.cf
User = email
Password = email
Dbname = linux
Table = email
Select_field = domain
Where_field = domain
Vi mysql:mailbox
User email
Password email
Dbname = linux
Table = email
Select_fileld = mailbox
Where_filed = username
Postconf �Cevirtual_alias_maps=mysql:/etc.postfix/mysql-alias.cf
Postconf �Cevirtualmailbox_domain=mysql:/etc/potfix/mysql-domain.cf
Postconf �Cevirtual_mailbox_maps=mysql:/etc/postfix/mysql-mailbox
验证:
Postmap �Cq “[email protected]”mysql:/etc/postfix/mysql-alias.cf
Postmap �Cq [email protected]:/etc/postfix/mysql-mailbox.cf
Postmap �Cq “westos.org”mysql:/etc/postfix/mysql-domain.cf
5设置接收邮件配合数据库
安装软件
Yum install �Cy dovecot dovecot-mysql(一定要装不装的话cat/var/log/maillog l:Unknown database driver 'mysql'
Oct 28 07:06:58 desktop20 dovecot:master: Error: service(auth): command startup failed, throttling
)
Cd /etc/dovecot/
Cd conf.d/
Vi 10-auth.conf
去掉!includeauth-sql.conf.ext 的注解让mysql验证
Vi auth-sql.conf.ext
Userdb {
Driver= sql
Args= /etc/dovecot/dovecot-sql.conf.ext
}
Cd /usr/share/doc/dovecot-2.0.9/example-conf
Cp dovecot-sql.conf.ext /etc/dovecot/
Cd /etc/dovecot/
Vi dovecot-sql.conf.ext更改如下:
Driver = mysql
Connect = host=localhost dbname=linuxuser=email password=email
Default_pass_scheme = PLAIN
Password_query = \
SELECTusername,domain,password \
FROMemail WHERE username = ‘%u’
Uer_query = SELECT mailbox,800 AS uid,,800 AS gid FROM email WHERE username= ‘%u’
Cd conf.d/
Vi 10-mail.conf
Mail_location = maildir:/home/email/%d/%n
First_valid_uid = 800
Cd ..
Vi dovecot.conf
telnet localhost 110 用telnet 验证
user [email protected]
pass test
6 extmail 和extman 做b/c机构的邮件系统
需要软件 extmail和extman
Makedir /var/www/extsuite/
Tar zxf extmail �CC /var/www/extsuite/
Tar zxf extman �CC /var/www/extsuite/
Cd /var/www/extsuite/
Mv extmail…..extmail
Mv extman….. extman
Cd extamn/doc
Mysql -uroot �Cp123456 < extmail.sql导入数据库
Mysql �Curoot �Cp123456 < init.sql 导入数据库
Cp mysql_virtual_alias_maps.cf/etc/postfix/mysql-alias.cf 吧配置文件移到/etc/postfix/下
Cp mysql_virtual_domains_maps.cf/etc/postfix/mysql-doamin.cf
Cp mysql_virtual_mailbox_maps.cf/etc/postfix/mysql-mailbox.cf
Mail [email protected]检验
Cd /var/www/extsuite/extmail
Less INSTALL
吧<virtualHost*:80>
serverName mail.example.com
DocumentRoot/var/www/extsuite/extmail/html/
scriptAlias /extmail/var/www/extsuite/extmail/html
SuexecUserGroup vuser vgroup
</VirtualHost> 复制的/etc/httpd/conf/httpd.conf 最后面
Vi /etc/httpd/conf/httpd.conf 如下:最后添加
NameVirtualHost *:80
<virtualHost *:80>
DocumentRoot/var/www/html
serverNameserver59.example.com
</virtualHost>
<virtualHost *:80>
serverName mail.extmail.org
DocumentRoot/var/www/extsuite/extmail/html/
scriptAlias /extmail/var/www/extsuite/extmail/html
SuexecUserGroup email email
</VirtualHost>
Ll �Cdcgi/
Chown �CR email.email cgi/
Vi /etc/hosts 如下:
192.168.0.8mail.extmail.org
which perl
需要 perl perl-CGI
Cp webmail.cf.default webmail.cf 就可以登录了
User postmaster 密码 extmail
让extman可以使用
Cd /var/www/extsuite/extman
Less INSTALL 复制
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html 到appach 的主配置文件下的extmail的配置中间如图:
Chown -R email.email cgi/ 更改此文件的权限让email.email为他的组和主
Cd ..
Cd extmail
Vi webmail.cf
SYS_SHOW_SIGNUP = 1 让用户可以注册 0 不可注册
Cd ..
Cd extman
Vim webman.cf 更改如下:
SYS_MAILDIR_BASE = /home/email
SYS_SESS_DIR = /tmp
SYS_BACKEND_TYPE = mysql
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
SYS_MYSQL_DB = extmail
让网页中显示系统信息
Cd /var/www/extsuite/extman/daemon
Vi /etc/rc.local 添加
/var/www/extsuite/extman/daemon/cmdserver&让后台运行
./cmdserver
Cd /extsuite/extman
Vim webman.cf 更改如下:
SYS_CAPTCHA_ON = 0 有没有验证码出现0没有1有
SYS_CAPTCHA_LEN = 6 验证码的长度
登录系统的support 和后台管理不知道密码在/extsuite/extman/docs/ 查看init.sql 中有记载
让extmail支持图片验证功能
安装软件perl-GD-2.45-1.el6.rfx.x86_64.rpm
Yum localinstallperl-GD-2.45-1.el6.rfx.x86_64.rpm 自动解决依赖性关系
让系统记录extmail的日志信息
Cd /var/www/extsuite/extmail
Vi webmail.cf
SYS_LOG_ON = 1
SYS_LOG_FILE = /var/log/extmail.log 日志文件的路径
如果缺少perl模块到www.cpan.org下载
Search unix::syslog 格式
Tar zxf Unix-Syslog-1.1.tar.gs
Cd Unix-Syslog-1.1
Less README
Perl Makefile.PL安装提示错误则按提示安装相应的模块
Yum install �Cy perl-ExtUtils-MakeMaker 然后再安装
Perl Makefile.PL
看到Looksgood 则安装成功
Make test 检查安装
Make install 安装
开启openLDAP Server 功能
提示Can’t locateRR.pm
rpm �Cq rrdtool
yum list rrdtool 查看rrdtool的版本
rpm -ivh rrdtool-perl-1.3….提示安装错误有依赖性
yum localinstall -y rrdtool-perl-1.3…. 本地安装自动解决依赖性
cd /var/www/extsuite/
cd extman/
cd addon/
cp -r mailgraph_ext/ /usr/local/
cd mailgraph_ext/
pwd
vi mailgraph-init 里面指明
BASEDIR=/usr/local/mailgraph_ext 所以要考的/usr/lopcal/下
./mailgraph-init start 启动提示有错误。安装相应的编译
Yum install perl-File-Tail -y 安装相应的模块
Tar zxf File-Tail-0.99.3.tar.gz
Cd File-Tail-…..
Perl Makefile.PL 安装perl的模块提示错误安装相应的错误
Yum list perl-Time-HiResyum install �Cy perl-Time-HiRes…r然后
Perl Makefile.PL
Make install
Vi /etc/rc.local 系统开机自动启动选项
/usr/local/mailgraph-init start 开机自动启动
配置相应的dovecot
Cd /etc/dovecot/conf.d/
Vi 10-mail-conf 更改如下:
Mail_location =maildir:/home/email/d/%n/Maildir
Cd ..
Vi dovecot-sql.conf.ext 更改里面的信息和mysql表里面的字段相互对应
/etc/init.d/dovecot restart
telnet localhost 110
user [email protected]
pass wxh
验证dovecot是否配置成功
Postfix stop
Tar zxf postfix-2.10.2.tar.gz
Cd postfix…
Yum list cyrus*
Yum install -y cyrus-sasl-devel …cyrus-sasl-plain …
Cd /postfix….
Make �Cf Makefile.init makefiles ‘CCARGS=-DHAS_MYSQL �CI/ur/include/mysql -DUSE_SASLUTH_DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS’ ‘AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz �Clm �CL/ur//lib64 �Clsasl2’ 安装编译postfix使它支持mysql和sasl
Make upgrade
Postfix -m 查看postfix支持的功能
Postconf -a 查看新编译的功能
Cyrus
dovecot
Postconf -A
Cyrus
Postconf -d | grep ^smtpd_sasl
Postconf -e smtpd_sasl_auth_enable=yes 打开病毒查杀功能
Postfix reload
Postfix start
telnet localhost 25
ehlo localhost
cd /etc/postfix-2.10.2
cd /etc/sasl2/
vi smtpd.conf编写如下:
pwcheck_method:auxprop
auxprop_plugin:sql
mech_list:PLAIN LOGINCRAM-MDDIGEST-MD5 NTLM
sql_engine:mysql
sql_hostnames:127.0.0.1
sql_user:extmail
sql_passwd:extmail
sql_database:extmail
ql_select: SELECT password FROMmailbox WHERE username = ‘%u@%r’
postfix reload
perl _MMIME::Base64 �Ce ‘print encode_base64(“\[email protected]\0test”);’
telnet localhost 25
ehlo localhost
rpm -qa | grep cyrus
rpm -ivh cyrus-sasl-sql-2.1.23-13…..有依赖关系
yum localinstall cyrus-sql-2.1.23-13……-y 如果提示没有key 则
yum localinstall cyrus-sql-2.1.23-13……--nogpgcheck
postfix reload
perl -MMIME::Base64 -e ‘printencode_base64(“\[email protected]\0test”);’生成密钥
telnet localhost 25
ehlo localhost
auth plain 下面加密钥
postconf -d | grep ^smtpd_tls
postconf -e smtpd_tls_security_level=may
postconf -e “smtpd_tls_session_cache_database= btree:/var/lib/postfix/smtpd_scache”
less TLS_README
cd /etc/pki/tls/certs
make postfix.pem 生成、密钥
postconf �Cd | grep ^smtpd_tls
postconf -e smtpd_tls_cert_file=/etc/pki/tls/certs/postfix.pem
postconf �Cn
cd /usr/share/spamassin/
/etc/init.d/spamassassin start
Getenforce 关闭selinux
安装杀毒软件postfix
Rpm -ivh clam*
Yum install -y libtool-ltdl.x86_64
Yum localinstall clam*
Freshclam 刷新病毒库
Cd /var/clamav/*
Chown clamav.clamav *
Freshclam
/etc/cron.daily 里面有每天刷新病毒库的系统守护进程
/etc/init.d/clamd start
Netstat -antlp
Clamdscan /var/ 扫描病毒
Clamdscan --remove /tmp/ 扫描并删除
Yum install �Cy rpm-build 安装rpm包制作软件
Yum localinstall Mailscanner….
Cd /mailscanner…
./install.sh
/etc/init.d/postfix stop
Chkconfid postfix off
Chkconfig MailScannet --list mailScanner 可以启动postfix
Cd /etc/MailScanner/
Yum install evince 安装pdf阅读得到软件
Vi Mailscanner.conf更改如下:
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir =/var/spool/postfix/hold
Outing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus_Scanners = clamd
Always Include SpamAssassin Report = yes
SpanAssassinUserState Dir = /var/spool/MailScanner/spamassassin
Mkdir /var/spool/MailScanner/spamassin
Cd /var/spool/MailScanner/
Chown -R postfix.postfix .
MailScanner -h
MailScanner --lint
Yum search unrar
Tar zxf rarlinux-3.8.0.tar.gz -C /usr/local/
Cd /usr/local/rar/
Ln �Cs /usr/local/rar/unrar
Vi Makefile
Less readme.txt
Make install
Which unrar
Unrar 有错误,
Yum install �Cy libstdc++.so.6
Ln -s /usr/local/bin/unrar /usr/bin/
Vi /etc/clamd.conf
Vi MailScanner.conf 更改如下:
Incomming Work User = clamav
Incoming Work Group = clamav
ClamdPort = 3310
Clamd Socket = /var/run/clamav/clamd.sock
Clamd Lock File = /var/lock/subsy/clamd
Clamd Use Threads = no
Mailscanner --lint
Cd /etc/MailScanner/
Vi Mailscanner.conf
Incoming work user =
Incoming Work Group = clamav
Incoming Work Permissions = 8640
ClamdPort = 3310
Clamd Socket = /var/run/clamav/clamd.sock
Clamd Lock file = /var/lock/subsys/clamd
Clamd Use Threads = no
LocalSocket /var/run/clamv/clamd.sock
Vi MailScanner.conf
Vi /etc/clamd.conf 更改的配置文件
Cd /etc/postfix/
Vi main.cf
Header_checks =regexp:/etc/postfix/header_checks
Vi header_checks
/^Received:/ HOLD