您的位置:首页 > 大数据 > 人工智能

安装CentOS5.0   postfix openwebmail mailscanner

2014-02-17 20:49 483 查看
安装CentOS5.0
GNOME桌面环境 服务器配置工具:全选 邮件服务器:squirrelmail spamassassin postfix dovecot
网络服务器:vnc-server 开发工具 管理工具 不选:kde环境
重启进入系统前 :防火墙禁用 SELINUX禁用

1.安装VNCSERVER /article/7575455.html
less /etc/sysconfig/vncservers
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp"
vncpasswd 设置ROOT的登录VNC用户口令
service vncserver start
less /root/.vnc/xstartup
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
service vncserver restart
vncviewer连接:192.168.0.100:2 输入密码连接

在CentOS 6.5设置VNC多用户登录1、安装VNCyum install vnc-server2、添加多个用户用户useradd user1 //添加用户user1passwd user1 //设置用户的linux登录密码su user1 //切换到用户user1vncpasswd //设置用户的user1登录密码exituseradd user2 //添加用户user2passwd user2 //设置用户的linux登录密码su user2 //切换到用户user2vncpasswd //设置用户的user2登录密码exit3、编辑vnc配置文件vi /etc/sysconfig/vncservers在最后加上:VNCSERVERS="1:user1 2:user2"VNCSERVERSVNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared" VNCSERVERSVNCSERVERARGS[2]="-geometry 1024x768 -alwaysshared"注意:-geometry 1024x768表示分辨率;-alwaysshared 表示允许多终端同时登陆4、打开对应的端口打开5901至5902 端口用于vnc //如果需要配置更多的桌面,增加端口即可iptables -I INPUT -p tcp --dport 5901:5902 -j ACCEPTiptables -A INPUT -p tcp --dport 5901:5902 -j ACCEPT永久保存service iptables save4.启动vncserver服务1)启动全部桌面 service vncserver start2)启动某一桌面 vncserver :1 //这里1表示第一个桌面5、停止vncserver服务1)停止全部桌面 service vncserver stop2) 停止某一桌面 vncserver -kill :1 //停止第1个界面,要用kill命令来杀掉界面1的进程6、查看当前有几个桌面在运行 service vncserver status7、让vncserver服务随机启动默认状态下,vncserver服务不是开机自动启动,需要手工启动。chkconfig --list vncserverchkconfig vncserver on保存后,重启测试。

2.更改系统--管理--邮件传输代理切换器 Postfix 确定

3.rpm -ivh perl-Compress-Zlib-1.41-1.2.el4.rf.i386.rpm

rpm -ivh perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm
rpm -ivh fp-linux-ws.rpm
yum list per* 先试下看能否连接服务器 如果不行可尝试更换DNS 25M 59个包
yum -y install perl*
tar -xvf MailScanner-4.52.2-1.rpm.tar.gz
./MailScanner-4.52.2-1/install.sh
rpm -ivh webmin-1.470-1.noarch.rpm
https://192.168.0.100:10000/ 改变WEBMIN语言:personal choice:Simplified Chinese(ZH_CN)
改变默认端口
系统-管理-服务器配置-服务
服务配置:dovecot httpd spamassassin vncserver smb named 开机自启动 postfix 去掉自启动
修改:/etc/postfix/main.cf header_checks local_domains
postmap hash:/etc/postfix/local_domains
修改:/etc/MailScanner/MailScanner.conf
DNS服务器:
创建主区域:factory.tgtex.com
邮件服务器:名称 factory.tgtex.com 优先级 10 邮件服务器 mail
地址:名称: mail.factory.tgtex.com 地址: 192.168.0.100
创建主区域:office.tgtex.com
邮件服务器:名称 office.tgtex.com 优先级 10 邮件服务器 mail
地址:名称: mail.office.tgtex.com 地址: 192.168.0.100
创建主区域:tiange.com
地址:名称: www.tiange.com 地址: 192.168.0.12
重启电脑验证各服务是否能正常启动
登陆:webmin:
服务器--Dovecot IMAP/POP3 Server
networking and protocols: IMAP POP3 IMAP(SSL) POP3(SSL) 全选 保存
User and login options--password Authentication source:Unix Shadow File 保存
系统--用户与群组
select all 系统用户 Export to batch file 备份一份系统用户
从批处理文件中创建、修改及删除用户
导入用户信息 直到左下角 显示 完成

马上覆盖shadow 密码影子文件

安装openwebmail
具体的要看你什么linux版本? 一般只有centos和redhat,fedora使用rpm包。下载地址 :http://openwebmail.org/openwebmail/download/redhat/rpm/release/2.53/你也可以使
用下列命令来安装:su - 切换至ROOT用户
cd /etc/yum.repos.d
wget -q http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
yum -y install openwebmail 安装软件 openwebmail.2.53 openwebmail-data-2.53 两个包及支持库

[openwebmail]
## Thomas Chung <tchung@openwebmail.org>
## 2008.05.29
name=Openwebmail for Fedora or Enterprise Linux
baseurl=http://openwebmail.org/openwebmail/download/redhat/rpm/release/
enabled=1
gpgcheck=1
gpgkey=http://openwebmail.org/openwebmail/download/redhat/rpm/release/RPM-GPG-KEY
-openwebmail
#metadata_expire=0

/var/www/cgi-bin/openwebmail/etc/defaults/dbm.conf
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock yes
smtpserver 127.0.0.1
less /var/www/cgi-bin/openwebmail/etc/openwebmail.conf
domainnames factory.tgtex.com (更改为自己定义的域名)
default_language zh_CN.GB2312 (更改为简体中文版介面)
default_iconset Cool3D.Chinese.Simplified (更改为简体中文版介面)
<default_signature> 删除中间的签名信息
</default_signature>
<page_footer>
田歌纺织内部邮件系统
</page_footer>

cd /var/www/cgi-bin/openwebmail
./openwebmail-tool.pl --init

/cgi-bin/openwebmail/openwebmail.pl

授权扫描权限:
chown postfix.postfix /var/spool/MailScanner/incoming/
chown postfix.postfix /var/spool/MailScanner/quarantine/
邮件扫描脚本文件 :/etc/MailScanner/reports/en/inline.sig.html inline.sig.txt
更改MAILSCANNER 发送邮件的标签,把对应的文件内容清空。收到邮件的时候,结尾就没有脚注了。html &text
Inline HTML Signature
 
Default: /opt/MailScanner/etc/reports/en/inline.sig.html
Default Linux: /etc/MailScanner/reports/en/inline.sig.html
Default FreeBSD: /usr/local/share/MailScanner/reports/en/inline.sig.html
 
假設 "Sign Clean Messages" 這個選項被啟動,當 MailScanner 完成此郵件的掃描時,會加註簽名在每個郵件的結
尾,你可以利用這個選項通知你的使用者,代表這個郵件已經被掃描,你也可增加任何你拒絕從此部伺服器傳
送的資訊在此檔中,這個檔案的內容是要符合插入到一個 HTML 檔案中。

Inline Text Signature
 
Default: /opt/MailScanner/etc/reports/en/inline.sig.txt
Default Linux: /etc/MailScanner/reports/en/inline.sig.txt
Default FreeBSD: /usr/local/share/MailScanner/reports/en/inline.sig.txt
 
假設 "Sign Clean Messages" 這個選項被啟動,當 MailScanner 完成此郵件的掃描時,會加註簽名在每個郵件的結
尾,你可以利用這個選項通知你的使用者,代表這個郵件已經被掃描,你也可增加任何你拒絕從此部伺服器傳
送的資訊在此檔中,這個檔案的內容是要符合插入到一個 Text 檔案中。

CentOS postfix安装切换mta 或者在开始的时候在服务器配置工具中:将system-switch-mail-gnome 包安装上
[root@localhost i386]# alternatives --config mta (选择2,postfix)+号为当前选定参数
[root@localhost i386]# rpm -e sendmail
[root@localhost i386]# cd /usr/sbin/
[root@localhost sbin]# mv sendmail sendmail.bak
[root@localhost sbin]# newaliases
[root@localhost sbin]# ln -s sendmail.postfix sendmail
yum -y install perl*
cp -arp openwebmail/ bak_1
yum list openwebmail
yum -y remove openwebmail.i386
ll
rm -rf openwebmail/
yum -y install openwebmail
vim openwebmail.repo
dos2unix openwebmail.repo
rm -rf openwebmail.repo
wget http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
yum clean all

CentOS 系统中安装postfix+dovecot+openwebmail
一、先卸载sendmain
[root@ser ~]# yum remove sendmail
二、安装postfix ,dovecot,cyrus-sasl
[root@ser ~]# yum -y install postfix
[root@ser ~]# yum -y install dovecot
[root@ser ~]# yum -y install cyrus-sasl
三、修改postfix的配置文件
[root@ser ~]# vim /etc/postfix/main.cf
myhostname = mail.eimam.com
mydomain = eimam.com
myorigin = eimam.com
inet_interfaces =all
mynetworks = 192.168.1.0/240
relay_domains = yjw.com, $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
重启 postfix 服务
[root@ser ~]# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@ser ~]# chkconfig postfix on
[root@ser ~]# chkconfig dovecot on
修改dovecot的配置文件
vim /etc/dovecot.conf
protocols = imap imaps pop3 pop3s
listen = *
在iptables 里开放25,110,143端口
[root@ser ~]# vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
重启iptables
[root@ser ~]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]ntrack_ftp
[root@ser ~]# chkconfig saslauthd on
修改 /etc/sysconfig/saslauthd
[root@ser ~]# vim /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
修改 /usr/lib/sasl2/smtpd.conf
[root@ser ~]# vim /usr/lib64/sasl2/smtpd.conf
pwcheck_method: saslauthd
测试 saslauthd
[root@ser ~]# service saslauthd restart
[root@ser ~]# testsaslautd -u yjw -p '020304'
0: OK "Success."
在postfix 的配置文件中,添加以下内容,使其支持SMTP认证
[root@ser ~]# vim /etc/postfix/main.cf
message_size_limit = 1073741824 # 邮件的大小为10M
default_process_limit = 50
default_destination_concurrency_limit = 20
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
测试 25端口
[root@ser ~]# telnet mail.yjw.com 25
Trying 192.168.1.2...
Connected to mail.yjw.com (192.168.1.2).
Escape character is '^]'.
220 mail.yjw.com ESMTP Postfix
EHLO 163.com
250-mail.yjw.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@ser ~]#
四、安装openwebmail
[root@ser ~]# vim /etc/yum.repos.d/openwebmail.repo
[openwebmail]
## Thomas Chung
## 2008.05.29
name=Openwebmail for Fedora or Enterprise Linux
baseurl=http://openwebmail.org/openwebmail/download/redhat/rpm/release/
enabled=1
gpgcheck=1
gpgkey=http://openwebmail.org/openwebmail/download/redhat/rpm/release/RPM-GPG-KEY-openwebmail
#metadata_expire=0
若这样安装不成功,先安装 perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm
[root@ser ~]# yum -y install openwebmail
[root@ser ~]# cd /var/www/cgi-bin/openwebmail/
[root@ser openwebmail]# ./openwebmail-tool.pl --init #出现Y/N时 ,按N.
修改openwebmail 的一些配置文件
[root@ser etc]# vim dbm.conf
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock no
[root@ser etc]]# cd defaults/
[root@ser defaults]# vim dbm.conf
dbm_ext .db
dbmopen_ext .db
dbmopen_haslock yes
smtpserver 192.168.1.2
[root@ser defaults]# vim openwebmail.conf
domainnames yjw.com
smtpserver 192.168.1.2
authpop3_server 192.168.1.2
再次初始化openwebmail
[root@ser defaults]# cd ../../openwebmail-tool.pl --init
出现Y/N 时,按Y。
把Postfix+Dovecot+Openwebmail 三者个格式统一下就行了
1.postfix 配置 main.cf
mail_spool_directory = /var/spool/mail
2.Dovecot 配置 Dovecot.conf
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u
3.Openwebmail.conf
mailspooldir /var/spool/mail
五、安装httpd
[root@ser ~]# yum - y install httpd
[root@ser ~]# chkconfig httpd on
[root@ser ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@ser ~]# vim /etc/httpd/conf/httpd.conf
ServerAdmin
root@yjw.com
ServerName mail.yjw.com:80
AddHandler cgi-script .cgi .pl
六、登陆openwebmail
在IE 中输入 mail.yjw.com/cgi-bin/openwebmail/openwebmail.pl, 这个地址是不是很长,那么我们来点短点的
在 httpd的 配置文件中添加 下面 内容:
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
这样在IE 中直接输入
mail.yjw.com/mail
七、安装反垃圾邮件软件,MailScanner
到MailScanner .org 上下载MailScanner-4.75.11-1.rpm.tar.gz
[root@ser ~]# tar zxvf MailScanner-4.75.11-1.rpm.tar.gz
[root@ser ~]# cd MailScanner-4.75.11
[root@ser MailScanner-4.75.11-1]# ./install.sh # 安装
安装 spamassassin
先检查您的系统内是否已经安装SpamAssassin软件包。在文本终端中输入:
[root@ser ~]# rpm -qa | grep spamassassin
spamassassin-3.1.9-1.el5
下载Mail-SpamAssassin-3.2.5.tar.gz
[root@ser ~]#tar -zxvf Mail-SpamAssassin-3.2.5.tar.gz
[root@ser ~]# cd Mail-SpamAssassin-3.2.5
[root@ser ~]# perl Makefile.PL
[root@ser ~]# make
[root@ser ~]# make install
打开/etc/MailScanner/目录中的MailScanner.conf文件,主要说明修改的关键部分:
%org-name% = yjw.com
%org-long-name% = yjw
web-site% = mail.yjw.com
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Incoming Work Group = postfix
Quarantine User = postfix
Quarantine Group = postfix
Always Include SpamAssassin Report = yes
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
SpamAssassin Install Prefix = /usr/bin
Log Speed = yes
Log Spam = yes
Log Silent Viruses = yes
Phishing Modify Subject = yes
更改incoming,quarantine 两个2个目录
[root@ser ~]# service spamassassin restart
[root@ser ~]# service spamassassin on
[root@ser ~]# service MailScanner restart
[root@ser ~]# service MailScanner on
[root@ser ~]# chown -R postfix:postfix /var/spool/MailScanner/*
[root@ser ~]# cd /var/spool/MailScanner/
[root@ser MailScanner]# ll
drwxr-xr-x 4 postfix postfix 4096 Apr 30 16:56 incoming
drwxr-xr-x 3 postfix postfix 4096 Apr 29 19:10 quarantine
drwx------ 2 postfix postfix 4096 Apr 30 15:58 spamassassin
在/etc/postfix/header_checks 中增加一句话:
[root@ser ~]# vi /etc/postfix/header_checks
/^Received:/ HOLD
设置中文邮件过滤规则
[root@ser ~]# wget -N -P
http://www.ccert.edn.cn/spam/sa/Chiese_rules.cf
/usr/share/spamassassin
使用计划任务来更新规则
[root@ser ~]# crontab -e
0 0 1 * * wget - N -P /usr/share/spamassassin
http://www.ccert.edu.cn/spam/sa/Chiness_rules.cf
; /etc/init.d/spamassassin restart
八、登陆openwebmail, 测试 收信,发信是否正常
[root@ser ~]# useradd tom
[root@ser ~]# passwd tom
tom
tom
[root@ser ~]# useradd yjw
[root@ser ~]# passwd yjw

CentOS系统安装配置postfix,saslauthd,dovecot
检查下sendmail
#rpm -qa | grep sendmail
停止掉
#/etc/init.d/sendmail stop
#chkconfig --level 0123456 sendmail off
#mv /usr/bin/newaliases /usr/bin/newaliases.orig
#mv /usr/bin/mailq /usr/bin/mailq.orig
#mv /usr/sbin/sendmail /usr/sbin/sendmail.orig 安装postfix
#yum -y install postfix
#vim /etc/postfix/main.cf
修改
(企业域名 btroot.org 邮件服务器 mail. btroot.org Mail服务器名 mail.btroot.org ip:11.22.33.44)
修改内容如下:
myhostname = mail.btroot.org
mydomain = btroot.org
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
mail.$mydomain, www.$mydomain, ftp.$mydomain
mynetworks_style = subnet
mynetworks = 127.0.0.0/8, localhost, 11.22.33.44
relay_domains = $mydestination
home_mailbox = Maildir/ //如果采用系统帐号作为邮件用户名,该目录为帐号下的目录
最后面添加(sasl加密算法支持)
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination,permit_mynetworks
smtpd_client_restrictions = permit_sasl_authenticated
安装saslauthd
必须先安装openssl 不然cyrus-sasl会报错 2.1.21的sasl版本,编译容易出错
#yum -y install openssl 关于saslauthd ,可以参考这里.
http://www.linuxfromscratch.org/blfs/view/cvs/postlfs/cyrus-sasl.html
下载saslauthd
#wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.25.tar.gz
#tar -xzvf cyc...
.#/configure --prefix=/usr \
--sysconfdir=/etc \
--with-dbpath=/var/lib/sasl/sasldb2 \
--with-saslauthd=/var/run/saslauthd --diable-anon --enable-login --enable-ntlm
#make && make install 要修改的smtpd.conf文件在/etc/sasl2/smtpd.conf
做个符号链接
#ln -s /etc/sasl2/smtpd.conf /usr/lib/sasl2/smtpd.conf
#vim etc/sysconfig/saslauthd
检查MECH=shadow
检查是否启动
#ps aux | grep saslauthd
#chklevel --2345 saslauthd on
#/etc/init.d/saslauthd start 验证下sasl
#/usr/sbin/testsaslauthd -u root -p '123456' -s smtp
0: OK "Success."
选择mta 会有两个一个sendmail 一个postfix
#alternatives --config mta
如果有sendmail 不要选它 我们用postfix 输入前面的数字既可
vi /usr/lib/sasl2/smtpd.conf
修改或者添加
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN log_level:3
安装dovecot
#yum -y install dovecot
vi /etc/dovecot.conf
修改或者添加
protocols = imap pop3 pop3s
listen = * # /etc/init.d/postfix start
# /etc/init.d/dovecot start
# /etc/init.d/saslauthd start
设置开机自启
#chkconfig –level 2345 postfix on
#chkconfig –level 2345 dovecot on
#chkconfig –level 2345 saslauthd on

CentOS系统中安装postfix邮件服务器

postfix是一个高效的邮件服务器,配置比sendmail简单,这里使用LAMP+postfix+dovecot+SquirrelMail搭建提供SMTP/POP3/IMAP的简单邮件服务。系统是CentOS6.2。
简单说明:
postfix是一个MTA即邮件传输代理。作为收件服务器。
dovecot是一个开源的IMAP和POP3邮件服务器。作为发件服务器。
准备工作:
1、卸载sendmail
yum remove sendmail
2、安装LAMP
yum install httpd mysql mysql-devel mysql-server php php-mysql php-bcmath php-gd php-mbstring php-xml php-imap
配置LAMP过程略过。
一、安装postfix
使用源码编译安装。
1、建立postfix所需的用户和组
建立postfix、postdrop组和postfix用户:
groupadd -g 2001 postfix
useradd -g postfix -u 1001 -s /sbin/nologin -M postfix
groupadd -g 2002 postdrop
2、安装必备软件包
yum install db*-devel
3、到官网http://www.postfix.org/ 找一个下载点下载postfix,目前稳定版为Postfix 2.9
cd /tmp
wget ftp://ftp.reverse.net/pub/postfix/official/postfix-2.9.3.tar.gz
tar -zxvf postfix-2.9.3.tar.gz
cd postfix-2.9.3
更新makefile文件,添加mysql、sasl认证支持:
make -f Makefile.init makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/include/mysql \
-DUSE_SASL_AUTH \
-DDEF_SERVER_SASL_TYPE=\"dovecot\"' \
'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm'
备注:-DUSE_SASL_AUTH表示启用SASL认证,-DDEF_SERVER_SASL_TYPE=\"dovecot\"表示使用dovecot做SASL模块。
继续安装:
make
make install
4、make install执行后会调用postfix-install脚本
这里设置如下,空白为直接按回车。
install_root: [/]
tempdir: [/tmp/postfix-2.9.3] /tmp/postfix
config_directory: [/etc/postfix]
command_directory: [/usr/sbin]
daemon_directory: [/usr/libexec/postfix]
data_directory: [/var/lib/postfix]
html_directory: [no] /var/www/html/postfix
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq]
manpage_directory: [/usr/local/man]
newaliases_path: [/usr/bin/newaliases]
queue_directory: [/var/spool/postfix]
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail]
setgid_group: [postdrop]
postfix安装在/usr/sbin/postfix,随后可以访问http://IP/postfix,查看Postfix Documentation。
5、检验postfix是否支持Dovecot SASL
postconf -a
结果显示dovecot,说明支持。
其它postconf命令:
postconf -n
postconf -m
postconf -d
二、安装dovecot
官网:http://dovecot.org,目前稳定版为dovecot 2.1.8。
1、安装必备软件包
yum install pam pam-devel
2、编译安装dovecot
cd /tmp
wget http://dovecot.org/releases/2.1/dovecot-2.1.8.tar.gz
tar -zxvf dovecot-2.1.8.tar.gz
cd dovecot-2.1.8
./configure --with-sql --with-mysql --with-ssl=openssl --with-pam
make
make install
dovecot安装在/usr/local/sbin/dovecot。
三、配置postfix
这里域名为live-in.org,FQDN(fully-qualified domain name)为mail.live-in.org。
0、修改主机名
hostname mail.live-in.org
vim /etc/hosts
127.0.0.1 mail.live-in.org localhost
1、编辑配置文件/etc/postfix/main.cf:
cp /etc/postfix/main.cf /etc/postfix/main.cf.bak
vim /etc/postfix/main.cf
1)设置邮件系统的主机名(FQDN)
找到:
#myhostname = host.domain.tld
修改为相应的域名:
myhostname = mail.live-in.org
2)设置本地域名
默认是将myhostname的第一部分去掉作为mydomain。
找到:
#mydomain = domain.tld
修改为相应的域名:
mydomin = live-in.org
3)设置发件人所在域名
找到:
#myorigin = $mydomain
去掉注释:
myorigin = $mydomain
这里和mydomain设置成一样。
4)设置postfix要接收邮件的域名
找到:
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
去掉注释:
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
5)不传递来自其它主机的邮件
找到:
#mynetworks_style = host
去掉注释:
mynetworks_style = host
6)设置postfix监听的网络接口
找到:
#inet_interfaces = all
去掉注释:
inet_interfaces = all
7)找到:
#alias_maps = hash:/etc/aliases
去掉注释:
alias_maps = hash:/etc/aliases
是为了防止出现警告信息:warning: dict_nis_init: NIS domain name not set - NIS lookups disabled。
8)设置邮件存储位置和格式
找到:
#home_mailbox = Maildir/
去掉注释:
home_mailbox = Maildir/
2、设置使用dovecot作为SASL认证,在最后加入:
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
3、启动postfix
/usr/sbin/postfix start
四、配置dovecot
1、复制样例配置文件
cd /usr/local/etc/dovecot
cp -R /usr/local/share/doc/dovecot/example-config/* /usr/local/etc/dovecot/
2、编辑配置文件dovecot.conf
vim dovecot.conf
找到以下几句将前面的注释去掉:
protocols = imap pop3 lmtp
listen = *, :: 修改为 listen = *
base_dir = /var/run/dovecot/
3、编辑配置文件10-master.conf
vim conf.d/10-master.conf
1)找到service auth块中的以下两句:
#unix_listener /var/spool/postfix/private/auth {
#mode = 0666
修改为:
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
2)找到:
default_login_user = dovenull
default_internal_user = dovecot
将注释去掉。
4、编辑配置文件10-auth.conf
vim conf.d/10-auth.conf
1)找到:
#disable_plaintext_auth = yes
修改为:
disable_plaintext_auth = no
允许明文密码验证。
2)找到:
auth_mechanisms = plain
修改为:
auth_mechanisms = plain login
使Outlook能使用与接收邮件服务器相同的设置认证SMTP。
5、编辑配置文件10-mail.conf
vim conf.d/10-mail.conf
找到:
#mail_location = maildir:~/Maildir
去掉注释:
mail_location = maildir:~/Maildir
6、建立dovecot用户
useradd -M -s /sbin/nologin dovenull
useradd -M -s /sbin/nologin dovecot
7、建立PAM认证文件
vim /etc/pam.d/dovecot
添加:
auth required pam_unix.so
account required pam_unix.so
8、查看配置文件是否有错
dovecot -n
没有报错即可。 9、启动dovecot
dovecot
报错:
doveconf: Fatal: Error in configuration file
/usr/local/etc/dovecot/conf.d/10-ssl.conf line 12: ssl_cert: Can't
open file /etc/ssl/certs/dovecot.pem: No such file or directory
是找不到/etc/ssl/certs/dovecot.pem文件。
进入dovecot解压后的源代码目录:
cd /tmp/dovecot-2.1.8/doc
mkdir -p /etc/ssl/certs
mkdir -p /etc/ssl/private
sh mkcert.sh
再次启动dovecot
dovecot
10、日志文件
这里postfix和dovecot日志都在/var/log/maillog里。
11、在域名的DNS解析处添加一个mail二级域名的A记录,和MX邮件交换记录。
自建的邮箱发给gmail和hotmail认为是垃圾邮件。还要做一个邮箱域名反向解析。即mail.xxx.com的A记录指向邮件服务器的IP,还要把该IP的PRT指向到mail.xxx.com。IP反向解
析需要联系上级的ISP来做了。因为我们对邮件域名有管理权,但对这个IP没有管理权。
12、整理下思路
这里设置的邮件用户为Linux系统内的实际用户,使用pam验证密码,邮件存储在~/Maildir(家目录下的Maildir目录中)。
但是root用户没有/home/root/Maildir这个目录如何收发邮件呢?
vim /etc/aliases
在最后加入:
root: test3
做一个别名重定向,随后更新资料库:
newaliases
建立test3用户:
useradd test3
另外好像root用户不能用POP3、IMAP登录发邮件?
五、安装SquirrelMail
SquirrelMail是一个基于PHP的webmail邮件系统。目前稳定版为squirrelmail-webmail-1.4.22。
1、下载SquirrelMail
cd /tmp
wget http://www.squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-webmail-1.4.22.tar.gz
tar -zxvf squirrelmail-webmail-1.4.22.tar.gz
mv squirrelmail-webmail-1.4.22 /var/www/html/webmail
chown -R apache:apache /var/www/html/webmail
2、配置参数
cd /var/www/html/webmail
./configure
会看到一个可选择的菜单,要修改几个地方:
输入D(Set pre-defined settings for specific IMAP servers),再输入dovecot
输入2(Server Settings),再输入1,设置Domain
输入10(Languages),再输入1,设置Default Language为zh_CN
输入10(Languages),再输入2,设置Default Charset为UTF8
建立SquirrelMail Data和Attachment:
mkdir -p /var/local/squirrelmail/data/
mkdir -p /var/local/squirrelmail/attach/
chown -R apache:apache /var/local/squirrelmail
访问:http://IP/webmail 登录SquirrelMail。

解决CentOS 6系统中postfix无法发信的问题

通过系统自带的rpm包安装postfix之后,执行mail -s...测试发信无法成功。maillog如下:
May 29 10:44:04 cl101 postfix/pickup[31536]: BA5662A0AFC: uid=0 from=<root>
May 29 10:44:04 cl101 postfix/cleanup[31559]: BA5662A0AFC: message-id=<20130529024404.BA5662A0AFC@cl101.dev.bizcn.com>
May 29 10:44:04 cl101 postfix/qmgr[31537]: BA5662A0AFC: from=<root@cl101.dev.bizcn.com>, size=3431896, nrcpt=1 (queue active)
May 29 10:44:04 cl101 postfix/smtp[31561]: fatal: unknown service: smtp/tcp
May 29 10:44:05 cl101 postfix/qmgr[31537]: warning: private/smtp socket: malformed response
May 29 10:44:05 cl101 postfix/qmgr[31537]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
May 29 10:44:05 cl101 postfix/master[31534]: warning: process /usr/libexec/postfix/smtp pid 31561 exit status 1
May 29 10:44:05 cl101 postfix/master[31534]: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling
May 29 10:44:05 cl101 postfix/error[31562]: BA5662A0AFC: to=<wmwu@bizcn.net>, relay=none, delay=1.3, delays=0.23/1/0/0.02, dsn=4.3.0, status=deferred
(unknown mail transport error)
这是由于postfix无法读取service文件所致。查看service的权限为640:
[root@cl101 etc]# ll|grep services
-rw-r-----. 1 root root 641243 Nov 7 2012 services
于是将其改为644:
[root@cl101 etc]# ll|grep services
-rw-r--r--. 1 root root 641243 Nov 7 2012 services
然后重试,即可解决此问题。

本文出自 “@快速畅通@” 博客,请务必保留此出处http://speediness.blog.51cto.com/760841/1359927
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: