linux环境下postfix+dovecot+webmail安装配置详解.docx_第1页
linux环境下postfix+dovecot+webmail安装配置详解.docx_第2页
linux环境下postfix+dovecot+webmail安装配置详解.docx_第3页
linux环境下postfix+dovecot+webmail安装配置详解.docx_第4页
linux环境下postfix+dovecot+webmail安装配置详解.docx_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

构建postfix邮件服务器(一)1、编译安装Postfixrootmail # groupadd -g 1200 postdroprootmail # groupadd -g 1000 postfix rootmail # useradd -M -s /sbin/nologin -u 1000 -g postfix -G postdrop postfixrootmail # tar zxf postfix-2.4.6.tar.gz rootmail # gunzip postfix-2.4.6-vda-ng.patch.gz rootmail # cd postfix-2.4.6rootmail postfix-2.4.6# patch -p1 main2.cfrootmail postfix# mv main.cf main.cf.bakrootmail postfix# mv main2.cf main.cfPostfix的启动控制rootmail postfix# postfix startpostfix/postfix-script: starting the Postfix mail systemrootmail postfix# netstat -anpt | grep :25tcp 0 0 :25 :* LISTEN 1995/master rootmail postfix# postfix check /若配置无误,不会反馈任何信息rootmail postfix# postfix reload /重新载入配置信息,而不需要重启Postfix服务postfix/postfix-script: refreshing the Postfix mail system rootmail postfix# postfix stoppostfix/postfix-script: stopping the Postfix mail systemrootmail postfix#配置基于Postfix构建简单电子邮件系统:1、 编辑main.cf文件,调整运行Postfix的基本参数rootmail postfix#vi main.cfinet_interfaces=99, /设置postfix服务监听的地址,缺省为allmyhostname= /设置postfix服务器使用的主机名mydomain= /设置postfix服务器使用的邮件域myorigin=$mydomain /设置外发邮件时发件人地址中的邮件域名mydestination=$mydomain,$myhostname /设置可接收的邮件地址中的域名home_mailbox=Maildir/ /设置邮件存储位置和格式2、 添加邮件用户的帐号rootmail postfix# groupadd mailusersrootmail postfix# useradd -g mailusers -s /sbin/nologin xiaowurootmail postfix# useradd -g mailusers -s /sbin/nologin juncairootmail postfix# passwd xiaowuChanging password for user xiaowu.New UNIX password: BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password: passwd: all authentication tokens updated successfully.rootmail postfix# passwd juncaiChanging password for user juncai.New UNIX password: BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password: passwd: all authentication tokens updated successfully.rootmail postfix#echo 12345 | passwd -stdin xiaowu /或这样赋予密码Changing password for user xiaowu.passwd: all authentication tokens updated successfully.3、 SMTP发送邮件测试rootmail postfix# telnet localhost 25Trying .Connected to localhost.localdomain ().Escape character is .220 ESMTP Postfixehlo 250 250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNmail from:250 2.1.0 Okrcpt to:250 2.1.5 Okdata354 End data with .subject: A TEST MAILHELLO!This is a test mail !.250 2.0.0 Ok: queued as 229784E100quit221 2.0.0 ByeConnection closed by foreign host.#grep 229784E100 /var/log/messages /查找发信状态rootmail postfix# cat juncai/Maildir/new/1300302205.V802Iac0c7M617334. Return-Path: X-Original-To: Delivered-To: Received: from localhost (localhost.localdomain ) by (Postfix) with SMTP id 229784E100 for ; Thu, 17 Mar 2011 03:02:45 +0800 (CST)subject: A TEST MAILMessage-Id: Date: Thu, 17 Mar 2011 03:02:45 +0800 (CST)From: To: undisclosed-recipients:;HELLO!This is a test mail !rootmail postfix#构建Dovecot服务器1、 编译安装Dovecot软件包rootmail #useradd M s /sbin/nologin dovecotrootmail #tar zxvf dovecot-1.1.4.tar.gzrootmail #cd dovecot-1.1.4rootmail dovecot-1.1.4# ./configure -sysconfdir=/etc -with-mysql & make & make install2、 配置Dovecot的运行参数(1) 建立dovecot.conf配置文件并进行简单设置rootmail dovecot-1.1.4# cp /etc/dovecot-example.conf /etc/dovecot.confrootmail dovecot-1.1.4#vi /etc/dovecot.confssl_disable = yesprotocols = imap pop3disable_plaintext_auth = nomail_location = maildir:/Maildir(2) 创建PAM认证文件rootmail dovecot-1.1.4# vi /etc/pam.d/dovecotauth required pam_nologin.soauth include system-authaccount include system-authsession include system-auth3、 启动Dovecot服务rootmail # /usr/local/sbin/dovecot -c /etc/dovecot.conf rootmail # netstat -anpt | grep dovecottcp 0 0 :110 :* LISTEN 3713/dovecot tcp 0 0 :143 :* LISTEN 3713/dovecot rootmail #4、 POP3接收邮件测试rootmail # telnet localhost 110Trying .Connected to localhost.localdomain ().Escape character is .+OK Dovecot ready.user juncai+OKpass juncai+OK Logged in.list+OK 1 messages:1 511.retr 1+OK 511 octetsReturn-Path: X-Original-To: Delivered-To: Received: from localhost (localhost.localdomain ) by (Postfix) with SMTP id 229784E100 for ; Thu, 17 Mar 2011 03:02:45 +0800 (CST)subject: A TEST MAILMessage-Id: Date: Thu, 17 Mar 2011 03:02:45 +0800 (CST)From: To: undisclosed-recipients:;HELLO!This is a test mail !.quit+OK Logging out.Connection closed by foreign host.rootmail #WEBMAIL邮件界面SquirrelMail的工作流程1、 依次安装squirrelmail程序包、中文语言包rootmail # tar jxvf squirrelmail-1.4.13.tar.bz2 -C /usr/local/apache2/htdocs/webmailrootmail # cd /usr/local/apache2/htdocs/webmail/rootmail webmail# tar jxvf /zh_CN-1.4.13-20071220.tar.bz22、 创建及调整数据目录、附件目录rootmail webmail# mkdir -p attach datarootmail webmail# chown -R daemon:daemon attach/ data/rootmail webmail# chmod 730 attach/3、 建立config.php配置文件rootmail webmail# cp config/config_default.php config/config.phprootmail webmail# vi config/config.php$squirrelmail_default_language = zh_CN; en_US$default_charset = zh_CN.UTF-8; iso-8859-1$domain = ;$smtpServerAddress = localhost;$smtpPort = 25;$imapPort = 143;$imap_server_type = dovecot;$data_dir = /usr/local/apache2/htdocs/webmail/data/;$attachment_dir = /usr/local/apache2/htdocs/webmail/attach/;4、 重新启动httpd服务,并在浏览器中登录squirrelmail系统rootmail webmail# ././bin/apachectl restart在该界面中可以完成发信、收信等电子邮件服务的基本操作。设置SMTP的用户认证 SMTP发信认证的常见形式如下:当用户通过SMTP协议向外部邮件域发送邮件时,服务器会要求用户提供用户帐户和口令进行身份认证,只有成功通过身份认证的用户才被允许向外部发送邮件,否则将拒绝发信请求。SMTP 认证,简单地说就是要求必须在提供了账户名和密码之后才可以登录 SMTP 服务器,这就使得那些垃圾邮件的散播者无可乘之机。增加 SMTP 认证的目的是为了使用户避免受到垃圾邮件的侵扰。在Postfix邮件系统中,可以使用Cyrus SASL(Cyrus Simple Authentication and Security Layer,Cyrus简单认证安全层)软件来实现基本的SMTP认证机制。使用以下命令验证Postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的# /usr/sbin/postconf -acyrusdovecot系统中默认已经安装了yrus SASL相关的软件包查看系统中已安装的与“cyrus”相关的RPM软件包rootmail # rpm -qa | grep cyruscyrus-sasl-plain-2.1.22-4cyrus-sasl-devel-2.1.22-4cyrus-sasl-lib-2.1.22-4cyrus-sasl-2.1.22-4rootmail #Postfix系统通过调用Cyrus SASL的函数库,使用Cyrus SASL提供的验证后台程序saslauthd验证系统帐号和密码:1、 设置Cyrus SASL函数库,并启动saslauthd服务rootmail # cp /usr/lib/sasl2/Sendmail.conf /usr/lib/sasl2/smtpd.confrootmail # vi /usr/lib/sasl2/smtpd.conf pwcheck_method:saslauthdrootmail # service saslauthd startStarting saslauthd: OK rootmail # chkconfig -level 35 saslauthd on2、 修改main.cf配置文件,添加SMTP认证相关的配置参数,并重新加载配置rootmail # vi /etc/postfix/main.cfsmtpd_sasl_auth_enable=yes /启用SMTP认证smtpd_sasl_security_options=noanonymous /禁止匿名登录 mynetworks=smtpd_recipient_restrictions= permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_non_fqdn_recipient,reject_unknown_recipient_domain,注:在上述配置参数中,后面几行设置的作用如下:mynetworks: 用于控制可以通过本服务器外发邮件的网络地址或IP地址,设置为是为了确保webmail系统可以正常发送邮件。smtpd_recipient_restrictions:设置收件人的地址过滤规则,其匹配策略是:“从上至下逐条检测,有匹配即停止”。其中:*permit_mynetworks:允许IP为mynetworks 的客户使用本邮件系统寄出邮件。*permit_sasl_authenticated:允许通过SMTP认证的用户向外发送邮件。 * reject_unauth_destination :当收件人地址不包括在postfix的授权网络内时,将拒绝发送该邮件。 Postfix授权网络包括由以下配置参数指定的域及其子域:mydestination、inet_interfaces、virtual_alias_maps、virtual_mailbox_maps、relay_domain。rootmail # postfix reloadpostfix/postfix-script: refreshing the Postfix mail system3、 测试SMTP发信认证rootmail # printf xiaowu | openssl base64eGlhb3d1MTIzNDU=rootmail # telnet 25Trying 99.Connected to (99).Escape character is .220 ESMTP Postfixehlo 250 250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-AUTH PLAIN DIGEST-MD5 LOGIN CRAM-MD5250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNmail from:250 2.1.0 Okrcpt to:554 5.7.1 : Relay access deniedauth login 334 VXNlcm5hbWU6eGlhb3d1334 UGFzc3dvcmQ6eGlhb3d1235 2.0.0 Authentication successfulmail from: 503 5.5.1 Error: nested MAIL commandrcpt to:250 2.1.5 Okdata354 End data with .This is mail to .250 2.0.0 Ok: queued as 02F3D4E107quit221 2.0.0 ByeConnection closed by foreign host.rootmail #没勾选我的服务器需要身份验证时:设置用户别名与邮件群组(用户别名是邮件系统中一个重要功能,主要用来实现邮件群发功能。邮件用户别名的实现依赖于aliases机制,而aliase机制需要用到查询表。1) Postfix的查询表 Postfix服务器在操作过程中经常需要做各式各样的转换与查询,例如,改写邮件地址、判断客户端是否来自授权网络、设定别名等,很多运行参数都可以通过查询表(lookup tab)来决定。举例来说,有四个学生用户zhangsan、lisi、mike、john,老师经常需要给这些学生发送相同内容的邮件,这就需要在收件人地址中逐个添加每个学生的邮件地址,过程会非常烦锁。如果Postfix服务器知道一个映射关系,例如名称student对应这四个学生用户zhangsan、lisi、mike、john,那么老师只要给student发送邮件,Postfix就会将邮件内容自动转发给这四个学生用户,大简化了用户的地址输入工作。由于main.cf文件本身的配置格式限制,无法逐一描述这样的关键字与值的对应映射关系。在实际应用中,通常把这些对应关系都写入到另外一个文件也就是查询表中,查询表保存了关键字(key)和一组值(value)间的简单对应关系。然后在main.cf配置文件中添加配置参数“alias_maps”,指向该文件即可。查询表对Postfix服务器很重要,很多运行参数都需要用到查询表(lookup tab)。维护查询表是邮件系统管理员的一项重要工作内容。例:修改hash.cf配置文件,使用“/etc/aliases”文件的hash数据作为查询表rootmail # vi /etc/postfix/main.cfalias_maps=hash:/etc/aliases2) 设置邮件别名实现群发功能根据Postfix服务器“alias_maps”配置参数的指定,可以将邮件用户的别名设置到对应的查询表文件中,例如“/etc/aliases”文件。在该文件中,每一行对应为一条别名设置记录,配置格式为”别名:地址1,地址2,地址3,.”.在对“/etc/aliases”文件的内容进行修改后,需要执行“newaliases”命令,以便重新生成“/etc/aliases”数据库文件。Postfix系统将识别并使用“/etc/aliases.db”文件中的设置。例:修改“/etc/aliases”文件,添加一条别名记录,将“student”对应为zhangsan、lisi、mike、john这四个用户,并更新到“/etc/aliases.db”数据库文件。rootmail # vi /etc/aliasesstudent:zhangsan,lisi,mike,john/etc/aliases 97L, 1544C writtenrootmail # newalia

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论