Linux 版 (精华区)

发信人: ken (洗心革面●好胡子), 信区: Linux
标  题: sendmail and openwebmail
发信站: 哈工大紫丁香 (2003年02月23日22:44:15 星期天), 站内信件

 
作者:peng     发表时间:2002/07/31 01:55pm
 
[这个贴子最后由peng在 2002/12/25 12:25pm 编辑]

 最近由于要把公司的mail服务器升级成webmail,看了不少资料。我的具体情况是
我现在的mail服务是redhat 7.2上运行sendmail-8.11.6-3。sendmail本身不支持
webmail.开始我用qmail+sqwebmail来代替现在的sendmail。主要看中qmail是因为
它对数据库的支持和对mail用户的数据存储格式,比sendmail要好的多。但由于我
开始用的mail用户是基于系统用户的,password采用的是md5加密格式,没办法导
成数据库用户。衡量一下,决定用openwebmail来实现webmail。优点是对现在的系
统改动不大,而且web界面良好。
  安装总体分为三部分:
1、安装系统;redhat 7.2
2、安装sendmail and apache。
3、安装openwebmail。
第一步,安装redhat 7.2。安装时最好安装成server,在选用服务时,选上
sendmail,www,ftp。默认安装的是apache-1.3.20,最近蜘蛛天天嚷着有安全漏
洞。也可以不装,从网上下在最新的安装版本。安装ftp是为了上传一些文件,用
完可关掉。分区时/var 要有足够的空间,因为sendmail要占用/var下的很大空间
。别的就没什么要注意的了。
 2、安装sendmail and apache。

 一、利用RedHat 7.2中的默认配置方便地设置一台利用SASL库进行用户名和密码
认证的SMTP服务器,以允许外面的用户以用户名和密码认证来relay邮件。 
 配置Sendmail 
1. 选择‘服务器系统’安装Redhat 7.2 
2. 进入目录 /usr/share/sendmail-cf/cf 。 
如果你没有该目录,说明你还没有安装sendmail-cf-8.11.6-3 RPM包,从你的安装
CD中安装它。 
3. 修改文件redhat.mc如下 
divert(-1) 
dnl This is the sendmail macro config file. If you make changes to 
this file, 
dnl you need the sendmail-cf rpm installed and then have to generate a 

dnl new /etc/sendmail.cf by running the following command: 
dnl 
dnl m4 /etc/mail/sendmail.mc > /etc/sendmail.cf 
dnl 
include(`../m4/cf.m4') 
VERSIONID(`linux setup for Red Hat Linux')dnl 
OSTYPE(`linux') 
define(`confDEF_USER_ID',``8:12'')dnl 
undefine(`UUCP_RELAY')dnl 
undefine(`BITNET_RELAY')dnl 
define(`confAUTO_REBUILD')dnl 
define(`confTO_CONNECT', `1m')dnl 
define(`confTRY_NULL_MX_LIST',true)dnl 
define(`confDONT_PROBE_INTERFACES',true)dnl 
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl 
define(`ALIAS_FILE', `/etc/aliases')dnl 
define(`STATUS_FILE', `/var/log/sendmail.st')dnl 
define(`UUCP_MAILER_MAX', `2000000')dnl 
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl 
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,
restrictqrun')dnl 
define(`confAUTH_OPTIONS', `A')dnl  
TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 
define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 
DAEMON_OPTIONS(`Port=25,Name=MTA')dnl 
DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl 
dnl define(`confTO_QUEUEWARN', `4h')dnl 
dnl define(`confTO_QUEUERETURN', `5d')dnl 
dnl define(`confQUEUE_LA', `12')dnl 
dnl define(`confREFUSE_LA', `18')dnl 
dnl FEATURE(delay_checks)dnl 
FEATURE(`no_default_msa',`dnl')dnl 
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl 
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')dnl 
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')dnl 
FEATURE(redirect)dnl 
FEATURE(always_add_domain)dnl 
FEATURE(use_cw_file)dnl 
FEATURE(use_ct_file)dnl 
FEATURE(local_procmail)dnl 
FEATURE(`access_db')dnl 
FEATURE(`blacklist_recipients')dnl 
EXPOSED_USER(`root')dnl 
dnl This changes sendmail to only listen on the loopback device 127.0.
0.1 
dnl and not on any other network devices. Comment this out if you want 

dnl to accept email over the network. 
#dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') 
dnl We strongly recommend to comment this one out if you want to protect
 
dnl yourself from spam. However, the laptop and users on computers 
that do 
dnl not have 24x7 DNS do need this. 
#dnl FEATURE(`accept_unresolvable_domains')dnl 
dnl FEATURE(`relay_based_on_MX')dnl 
MAILER(smtp)dnl 
MAILER(procmail)dnl 
其中,我加了下面的行:  
1. TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 
2. define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 

3. DAEMON_OPTIONS(`Port=25,Name=MTA')dnl 
4. DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl
还要注掉两行:
#dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') 
#dnl FEATURE(`accept_unresolvable_domains')dnl 
注: 
第1,2行 移走前面的注释,打开相应的各种认证机制。 
第3,4行 设置相应的MTA和MSA所在的端口号。 
注意:要是你的系统是redhat 7.1的话,sendmail也是系统默认安装的话,还要打
开以下注解:
1. dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') 
2. dnl FEATURE(`accept_unresolvable_domains')dnl 
第1行 允许通过网络连接Sendmail。 
第2行 禁止不可解析的域名relay邮件 
最后运行 
#m4 /usr/share/sendmail-cf/cf/redhat.mc > /etc/sendmail.cf 
写到/etc/sendmail.cf文件中 

四: 设置SASL认证方案 
1. 运行下面的命令,确保SASL被编译进Sendmail. 
#/usr/sbin/sendmail -d0.1 -bv root |grep SASL 
输出应该类似如下面: 
NETUNIX NEWDB QUEUE SASL SCANF SMTP USERDB XDEBUG 
确保你能看见上面的文本中的 SASL 
2. 测试端口25,确保输出AUTH提示行。 
#telnet localhost 25 
Trying 127.0.0.1... 
Connected to smtp.domain.com. 
Escape character is '^]'. 
220 smtp.domain.com ESMTP Sendmail 8.11.2/8.11.2; Sun, 1 July 2001 17:
56:54 -0800 
EHLO localhost 
250-smtp.domain.com Hello IDENT:root@smtp.domain.com [127.0.0.1], 
pleased to meet you 
250-ENHANCEDSTATUSCODES 
250-EXPN 
250-VERB 
250-8BITMIME 
250-SIZE 
250-DSN 
250-ONEX 
250-ETRN 
250-XUSR 
250-AUTH LOGIN PLAIN 
250 HELP 
quit 
221 2.0.0 smtp.domain.com closing connection 
Connection closed by foreign host. 
你需要至少看见AUTH行中有LOGIN PLAIN在那里,否则不能relay mail。 

3. 最后,运行/etc/rc.d/init.d/sendmail restart重新启动Sendmail。 
4、添加用户。我用的是系统默认用户,只要添加系统用户就可以了。
 例如,添加用户peng,组是mailuser, 放在/home/mailuser目录中,没有登陆
shell.
 groupadd -g 2000 mailuser
 useradd -d /home/mailuser/peng -g 2000 -s /bin/false peng
 passwd peng
 输入两遍密码。
 在这里,为了安全起见,我没有给用户添加可用的shell。用户可通过
openwebmail界面更改密码。

五、: 设置Windows的Outlook Express。 
1. Outlook Express仅仅使用 PLAIN LOGIN 认证机制,确保上面的telnet 
localhost 25中的AUTH行 
输出PLAIN LOGIN即可。 
2. 在‘工具’-‘帐号’-‘属性’-‘服务器‘- 
’发送邮件服务器’中选中‘我的服务器需要认证’

六、 安装pop3,从redhat 7.2的光盘上有imap-2000c-15.i386.rpm
rpm -ivh imap-2000c-15.i386.rpm
OK!
 验证:netstat -a |grep pop

输出 ------tcp 0 0 * : pop3 *:* listen 
ok了!
 安装apache:
 要是系统默认安装,就可以跳过。要是没有安装,从www.apache.org上下载最新
版本。我用的是httpd-2.0.39.tar.gz,官方说是当前最好的了。
 安装步骤:
 tar -zxvf httpd-2.0.29.tar.gz
 cd httpd.2.0.29
 ./configure --prefix=/var/www
 make
 make instal
 启动:/var/www/bin/apachectl start
(详细配置,你可以看httpd.2.0.29目录中的install文件)
OK!到这,apache配置完成。
 3、安装openwebmail。
 下载相关的软件:
1、CGI.pm-2.74.tar.gz
2、MIME-Base64-2.12.tar.gz
3、libnet-1.0901.tar.gz
4、Download openwebmail-1.65.tgz程式套件,
5、perl.5.XX   (redhat 7.2系统自带)
 把前三个文件放在/tep目录下:

(1)For CGI.pm do the following:
cd /tmp
tar -zxvf CGI.pm-2.74.tar.gz
cd CGI.pm-2.74
perl Makefile.PL
make
make install
(2)For MIME-Base64 do the following:
cd /tmp
tar -zxvf MIME-Base64-2.12.tar.gz
cd MIME-Base64-2.12
perl Makefile.PL
make
make install
(3)For libnet do the following:
cd /tmp
tar -zxvf libnet-1.0901.tar.gz
cd libnet-1.0901
perl Makefile.PL
make
make install
(4)For openwebmial 主程式
cd /var/www
tar -zxvf openwebmail-1.65.tgz
mv /var/www/data/openwebmail  /var/www/htdocs/

修改设定值:

(1)vi /var/www/cgi-bin/openwebmail/auth_unix.pl)
my $unix_passwdfile to /etc/shadow (找到这两行,修改。)
my $unix_passwdmkdb to none
(2)vi /var/www/cgi-bin/openwebmail/etc/openwebmail.conf
下列是 RedHat 7.2 openwebmail.conf 的內容,请修改如下:
------------------------------------------------------------------------
--------------
# Open WebMail configuration file
# This file contains just the overrides from openwebmail.conf.default
# please make all changes to this file.
# This file set options for all domains and all users.
# To set options on per domain basis, please put them in sites.
conf/domainname
# To set options on per user basis, please put them in users.
conf/username
domainnames auto
auth_module auth_unix.pl
mailspooldir /var/spool/mail
dbm_ext .db
dbmopen_ext none
ow_cgidir /var/www/cgi-bin/openwebmail
ow_htmldir /var/www/htdocs/openwebmail
logfile /var/log/openwebmail.log
spellcheck /usr/bin/aspell
default_language zh_CH.GB2312   -----默认简体中文

------------------------------------------------------------------------
------

(3)为避免"Returned mail: see transcript for details"的错误信息,请做下列
连接:

cd /etc/smrsh
ln -s /var/www/cgi-bin/openwebmail/vacation.pl /etc/smrsh/vacation.pl

大功告成、进行测试!
添加用户:
useradd -d /home/test test
passwd test ----创建密码
輸入以下网址
http://yourservername/cgi-bin/openwebmail/openwebmail.pl
如果你觉得输入这么长的地址太麻烦,可以做个index.html连接。
cd /var/www/htdocs/
vi index.html
------------------------------------------------------
<html>
<head>
<META HTTP-EQUIV="REFRESH" CONTENT="1; URL=http:
/cgi-bin/openwebmail/openwebmail.pl">
</head>
<body>
</body>
</html>
-----------------------------------------------------------
 重启动apache:/var/www/bin/apachectl restart
输入://youservername ,看看是不是可以了!

 以上是本人亲自安装过程,要是有什么问题和错误,欢迎讨论。
 联系方式:e-mail:peng@96633.net
            



 
 

------------------------------------------------------------------------
--------
此文章相关评论: 
 
该文章有22个相关评论如下:(点这儿可以发表评论)
 
jzcjy 发表于: 2002/07/31 02:36pm
 
有一个 for redhat7.2的,openwebmail-1.65-rh7x,我现在就是用的这个。 
  
peng 发表于: 2002/07/31 03:06pm
 
 是吗?从哪下载啊?不是在安装盘上吧?:) 
  
wind521 发表于: 2002/07/31 04:11pm
 
好人呀!
鼓掌
 
  
ericfung 发表于: 2002/07/31 06:02pm
 
请问可否两个邮箱系统(sendmail和qmail)共存?我现在卸载了sendmail装了
qmail,我可否再装sendmail,当我想用哪个系统就用哪个,这样可以吗?有什么要注
意呢? 
  
peng 发表于: 2002/07/31 08:38pm
 
 在同一机器上,好像有点难度,同时占用相同的端口啊!也没什么实在意义吧?
 
  
jzcjy 发表于: 2002/08/01 07:52am
 
# wget ftp://openwebmail.
org/pub/redhat-7x-installer/rh73/openwebmail-20020712-rh73.tgz
tar zxvf ./openwebmail-20020712-rh73.tgz
./install
其中的cgi imap等模块都包含了,只要你原来的sendmail和apache 好用,现在就可
以在你的
web中http://servername/cgi-bin/openwebmail/openwebmail.pl 登录邮件系统了
,不过这个可以支持中文的GB2312,但是图标中的没有简体中文版的,我是在
/var/www/cgi-bin/openwebmail/etc/lang/建立了一个china_sp目录,将english
目录下的*gif考进来后,用在修改为中文版的。就ok.  


 
  
peng 发表于: 2002/08/01 10:07am
 
 看来我是太心急了,没有好好看看,就开始蛮干了!:)
 还好安装也不太麻烦,不然就亏大了。:( 
  
ericfung 发表于: 2002/08/01 10:57am
 
我不是同时使用,可以切换就可以了. 
  
peng 发表于: 2002/08/01 12:02pm
 
 哪你得在服务器上停止一个服务,在启动另一个。太麻烦了吧? 
  
水鬼 发表于: 2002/08/01 02:49pm
 
[quote][b]下面引用由[u]peng[/u]在 [i]2002/08/01 10:07am[/i] 发表的内容:
[/b]
看来我是太心急了,没有好好看看,就开始蛮干了!:)
 还好安装也不太麻烦,不然就亏大了。:(
[/quote]
呵呵,那是不是用了 openwebmail-20020712-rh73.tgz,就不必象你的教程那样麻
烦了呢?我还是先问清楚再玩,否则走弯路不打紧,就怕迷路了。嘻嘻。

┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
⊙⊙⊙⊙⊙⊙⊙⊙┼⊙⊙┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙⊙⊙⊙┼┼┼┼⊙⊙⊙⊙┼┼┼⊙⊙⊙⊙⊙┼┼⊙⊙┼┼
┼┼⊙⊙
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼
┼⊙⊙┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼┼┼⊙⊙⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼┼⊙⊙
⊙⊙┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼┼⊙⊙┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼┼┼⊙
⊙┼┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼┼⊙⊙
⊙⊙┼┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼┼⊙⊙┼
┼⊙⊙┼
┼┼┼⊙⊙┼┼┼┼⊙⊙┼┼⊙⊙┼┼┼⊙⊙⊙⊙⊙┼┼⊙⊙┼┼⊙⊙┼⊙⊙┼┼
┼┼⊙⊙
┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼
┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼
┼┼┼┼

 
  
peng 发表于: 2002/08/01 03:11pm
 
 不知这个在redhat 7,2下能不能用啊?我人比较保守,不敢用新的东西,怕出事
,担待不起。linnx喜欢用稳定版本。听说linnx-x.y  y要是奇数,说明是测试版
。y偶数是稳定版本。:) 
  
z2000c 发表于: 2002/08/23 05:10pm
 
谣传吧? 
  
peng 发表于: 2002/08/23 06:48pm
 
 不是谣传,的确是redhat的版本发行规则。 
  
zzher 发表于: 2002/10/14 06:58pm
 
为什么我按上面的做出来一切都好,只是SMTP认证可有可无都可发邮件 
  
peng 发表于: 2002/11/10 01:34pm
 
 修改文件redhat.mc时,把以下两行注释掉:--前面加#
 # dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') 
 # dnl FEATURE(`accept_unresolvable_domains')dnl 
   这样就可以实现smtp 认证了。
 
  
arnold 发表于: 2002/11/13 08:23pm
 
前面有dnl就是注释,并不是用#来注释,可不要张冠李戴哦。 
  
arnold 发表于: 2002/11/13 09:28pm
 
完全按楼主的介绍,改了/usr/lib/sasl/Sendmail.conf中的认证方法,使用
sasldb中的用户就是不能收发邮件,反而用系统用户就能收发邮件,什么地方出问
题了? 
  
lanbor 发表于: 2002/12/23 04:59pm
 
Peng 兄 !!能不能把你做好的openwebmail界面给帖图一下,我想看看
openwebmail长什么样,是不是比sqwebmail漂亮。 :) 谢! 
  
lanbor 发表于: 2002/12/23 05:10pm
 
Peng兄,能否将openwebmail的界面贴图一下?我想看看好不好看!!sqwebmail太
难看了。
谢。。。另外qmail能用openwebmail吗? 
  
peng 发表于: 2002/12/23 05:26pm
 
[这个贴子最后由peng在 2002/12/23 05:28pm 编辑]

  ;(
 
  
coofer 发表于: 2003/01/04 01:24am
 
Internal Server Error
The server encountered an internal error or misconfiguration and was 
unable to complete your request.
Please contact the server administrator, root@linux and inform them of 
the time the error occurred, and anything you might have done that may 
have caused the error.
More information about this error may be available in the server error 
log.


------------------------------------------------------------------------
--------

Apache/1.3.24 Server at 127.0.0.1 Port 80
这是我的提示错误。我按照上面说的方法做的,我怀疑是PERL语言的解析问题但我
运行了如下命令结果如下:到底是什么原因呢,希望各位能帮帮我,谢谢
[root@linux htdocs]# rpm -qa |grep perl
perl-DB_File-1.75-34.99.6
perl-HTML-Parser-3.26-2
perl-Parse-Yapp-1.05-15
perl-XML-Encoding-1.01-9
perl-XML-Dumper-0.4-12
perl-5.6.1-34.99.6
perl-CPAN-1.59_54-34.99.6
perl-NDBM_File-1.75-34.99.6
perl-DateManip-5.40-15
perl-HTML-Tagset-3.03-14
perl-libnet-1.0901-17
perl-MIME-Base64-2.12-14
perl-Storable-1.0.14-15
perl-libwww-perl-5.63-9
perl-XML-Grove-0.46alpha-11
perl-libxml-perl-0.07-14
perl-XML-Twig-2.02-9
perl-SGMLSpm-1.03ii-4
perl-CGI-2.752-34.99.6
groff-perl-1.17.2-12
perl-Digest-MD5-2.16-15
perl-libxml-enno-1.02-15
perl-URI-1.17-16
perl-XML-Parser-2.30-15
 
  
coofer 发表于: 2003/01/04 01:58am
 
还有这是我/var/www/logs/error_log的内容[Fri Jan  3 09:50:59 2003] 
[error] [client 192.168.0.96] Premature end of script headers: 
/var/www/cgi-bin/openwebmail/openwebmail.pl
Can't do setuid
[Fri Jan  3 09:51:00 2003] [error] [client 192.168.0.96] Premature end 
of script headers: /var/www/cgi-bin/openwebmail/openwebmail.pl
 
  
 
 
   

------------------------------------------------------------------------
--------
Copyright ? ChinaUnix.net  *  转载请注明出处及作者 
--
□太空服(Pifeng)
□激光剑(Fazhang)
□航空母舰(Motor)
□绣花小鞋(Shoes)
□轻纱长裙(Skirt)

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.237.232]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:212.030毫秒