LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 995|回复: 4

建立小型postfix邮件服务器

[复制链接]
发表于 2007-2-9 15:46:20 | 显示全部楼层 |阅读模式
postfix+cyrus-sasl+dovecot+httpd+openwebmail的配置,建立小型postfix邮件服务器

Step0、实验环境:
  先决条件:配好DNS及安装好APACHE,并在ntsysv中加入他们。

  网络域名:piertek.cn
  DNS主机名称:mail.piertek.cn
  DNS主机IP地址:192.168.1.114
  邮件主机名称:mail.piertek.cn
  邮件主机IP地址:192.168.1.114
  操作系统:RedFLAG DC 5.0中文版
  无防火墙和不启动SELinux服务:  
  连接软件包组时,全选“开发工具”项目内的所有内容;
Step1、DNS服务器的配置:
  参考资料“Red Hat Enterprise Linux 4.1下配置BIND -9.2.4-2安装笔记”
  连接地址:http://www.********.com/bbs/showthread.php?t=2866
Step2、安装所需要的软件清单:
  postfix-2.2.5-3.rhel4.rpm
  postfix-pflogsumm-2.1.5-4.2.rhel4.rpm
  cyrus-sasl-2.1.19-5.rhel4.i386.rpm
  dovecot-0.99.11-2.rhel4.1.rpm
  httpd-2.0.52-12.ent.rpm
  perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm(缺)
  perl-suidperl-5.8.5-12.1.1.i386.rpm
  perl-Compress-Zlib-1.34-1.2.el4.rf.i386.rpm(缺)
  perl-CGI-SpeedyCGI-2.22-1.2.el4.rf.i386.rpm(缺)
  perl-5.8.5-12.1.i386.rpm
  openwebmail-2.51-1.i386.rpm(缺)

--------------------------------------------------------------------------------------------------
说明:软件清单中的postfix+cyrus-sasl+dovecot+httpd也可以在安装系统时一起安装。
  安装openwebmail 2.51系统所需要的软件可以到下列地址下载:
  http://openwebmail.org/openwebmail/download/redhat/rpm/release
--------------------------------------------------------------------------------------------------

Step3、postfix的安装过程:

  #killall sendmail (停止所有的Sendmaail进程)
  sendmail: no process killed
    # rpm -ivh postfix-2.2.5-3.rhel4.i386.rpm
  Preparing...   ########################################### [100%]
    1:postfix   ##################################### [100%]
  链接 /usr/share/man/man8/sendmail.8.gz 到从mta-sendmailman(/usr     /share /man /man1/sendmail.1.gz mta-sendmailman)不正确

Step4、启动postfix + dovecot服务过程:

  修改/etc/dovecot.conf文件:
  #protocols = imap imap3
  更改为:
  protocols = imap pop3 pop3s (启动imap pop3 pop3s功能)

  auth_passdb = pam
  更改为:
  auth_passdb = shadow

  # service dovecot restart(重新启动dovecot服务)
  停止 Dovecot Imap:                   [ 确定 ]
  启动 Dovecot Imap:                   [ 确定 ]

Step6、修改/etc/postfix/main.cf文件:

  #myhostname = host.domain.tld
  更改为:
  myhostname = mail.piertek.cn(指定运行Postfix邮件系统的主机名称)

  #mydomain = domain.tld
  更改为:
  mydomain = piertek.cn(指定Postfix邮件系统使用的域名比例:easy.com)

  #myorigin = $mydomain
  更改为:
  myorigin = piertek.cn (指定发件人所在的域名比例:easy.com)

  #inet_interfaces = all
  更改为:
  Inet_interfaces =all (指定Postfix邮件系统监视的网络接口)注:将inet_interfaces =localhost注释掉

  #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
  更改为:
  mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain,
  ftp.$mydomain (指定Postfix接收邮件时收件人的域名)

  #mynetworks = host
  更改为:
  mynetworks = host (指定您所在的网络地址)

  # service postfix start (重新启动postfix服务)
  Shutting down postfix:                 [ 确定 ]
  Starting postfix:                   [ 确定 ]

Step7、端口测试:

  # telnet mail.easy.com 25 (测试25端口)Trying 127.0.0.1...
  Connected to localhost.localdomain (127.0.0.1).
  Escape character is '^]'.
  220 mail.easy.com ESMTP Postfix
  quit
  221 Bye
  Connection closed by foreign host.
  # telnet mail.easy.com 110 (测试110端口)Trying 127.0.0.1...
  Connected to localhost.localdomain (127.0.0.1).
  Escape character is '^]'.
  +OK dovecot ready.
  quit
  +OK Logging out
  Connection closed by foreign host.
  #ntsysv在启动项中加入postfix ,dovecot两项服务。

Step8、安装openwebmail 2.51软件:

  # service httpd restart (启动httpd服务)
  停止 httpd:                     [ 确定 ]
  启动 httpd:                     [ 确定 ]
  # rpm -ivh perl-CGI-SpeedyCGI-2.22-1.2.el4.rf.i386.rpm
  # rpm -ivh perl-Compress-Zlib-1.34-1.2.el4.rf.i386.rpm
  # rpm -ivh perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm

# rpm -ivh openwebmail-2.51-1.i386.rpmwarning: openwebmail-2.51-1.i386.rpm: V3 DSA signature: NOKEY, key ID cfb164d8
  Preparing...   ######################################### [100%]
  1penwebmail   ###################################### [100%]
   
  You may login with non-root account from
  http://mail.easy.com/cgi-bin/openwebmail/openwebmail.pl

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

  Please change './etc/dbm.conf' from

  dbm_ext       .db
  dbmopen_ext       none
  dbmopen_haslock     no

  to

  dbm_ext       .db
  dbmopen_ext       .db
  dbmopen_haslock     no


  And execute './openwebmail-tool.pl --init' again!

  ps: If you are running openwebmail in persistent mode,
    don't forget to 'touch openwebmail*.pl', so speedycgi
    will reload all scripts, modules and conf files in --init.

Step9、修改 /var/www/cgi-bin/openwebmail/etc/openwebmail.conf 文件:

  domainnames     auto
  更改为:
  domainnames     piertek.cn (更改为自己定义的域名)

  default_language       en
  更改为:
  default_language   zh_CN.GB2312 (更改为简体中文版介面)

  default_iconset   Cool3D.Englist
  更改为:
  default_iconset   Cool3D.Chinese.Simplified (更改为中文3D按键)
  Step10、修改/var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf文件:

  smtpserver       127.0.0.1
  更改为:
  smtpserver       192.168.1.114 (更改smtp服务器的地址)

  authpop3_server       localhost
  更改为:
  authpop3_server       192.168.1.114(更改pop3服务器的地址)

Step11、修改/var/www/cgi-bin/openwebmail/etc/defaults/dbm.conf文件:

  dbmopen_ext     none
  更改为:
  dbmopen_ext     .db



  smtpserver       192.168.1.114 (添加smtp服务器的地址)

Step12、继续运行openwebmail-tool.pl文件:

  # ./openwebmail-tool.pl --init

  creating db /var/www/cgi-bin/openwebmail/etc/maps/b2g ...done.
  creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b ...done.
  creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar ...done.
  Welcome to the Open WebMail!

  This program is going to send a short message back to the developer,
  so we could have the idea that who is installing and how many sites are
  using this software, the content to be sent is:

  OS: Linux 2.6.9-11.EL i686
  Perl: 5.008005
  WebMail: Open WebMail 2.51 20050228

  Send the site report?(Y/n) y (输入y,然后按回车键)
  sending report...

  Thank you.

Step13、增加限制用户发送电子邮的权限:


  # useradd fandy(增加本地用户:fandy)
  # useradd yer(增加本地用户:yer)
  # useradd biao(增加本地用户:biao)

  # passwd yer(设置本地yer用户的密码)
  Changing password for user yer.
  New UNIX password:
  Retype new UNIX password:
  passwd: all authentication tokens updated successfully.

  # passwd fandy(设置本地fandy用户的密码)
  Changing password for user fandy.
  New UNIX password:
  Retype new UNIX password:
  passwd: all authentication tokens updated successfully.

  # passwd biao(设置本地biao用户的密码)
  Changing password for user biao.
  New UNIX password:
  Retype new UNIX password:
  passwd: all authentication tokens updated successfully.



  在/etc/postfix/目录下建立local_domains文件,内容如下:

  piertek.cn       OK
  mail.piertek.cn   OK

  为local_senders、local_domains两个文件建立hash:


  # postmap hash:/etc/postfix/local_domains


Step14、测试webmail方式收发电子邮件:

  在ie中输入以下地址:
  http://mail.piertek.com/cgi-bin/openwebmail/openwebmail.pl

可用/usr/sbin/postfix start命令启动
注:在客户端建帐户时输xxx@piertek.cn即可
可发到外面,但是不能从外面发进来,DNS问题。
可通过webmin方式管理。
 楼主| 发表于 2007-2-13 16:41:38 | 显示全部楼层
怎么没有回复呀?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-13 16:43:38 | 显示全部楼层
我是在红旗上做的,花了很大的功夫。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-14 22:12:48 | 显示全部楼层
请教一下弟兄们,我做的这个postfix服务器,没有与mysqld服务结合起来,只适合小规模的应用,mysqld是用来存储用户名密码的。不知道怎么样才能实现?
回复 支持 反对

使用道具 举报

发表于 2007-2-15 09:06:30 | 显示全部楼层
超敬佩,居然用红旗作服务器。超佩服~~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表