Postfix+ Courier-imap+Smtp的安装配置(Gentoo)-A

Postfix+ Courier-imap+Smtp的安装配置(Gentoo)-A

Postfix+ Courier-imap+Smtp的安装配置(Gentoo)

一. Postfix 安装手册

什么是 Postfix

Postfix 是由 Wietse Venema's (http://www.porcupine.org/wietse/) 开发用来替代使用最广的 Sendmail 程序;此外,Postfix 试图在使用上更快速、简单管理及安全,同时与 sendmail 保持足够的兼容性而不打扰系统中已存在的使用者。尤其近来 Sendmail 经常被发现 local root 的攻击漏洞加上 Sendmail 发展已久,在安装及设定上并不是那么简单,所以有许多单位或网管人员逐渐改采 Postfix 来做为邮件转递的代理者(MTA,Mail Transfer Agent)

二. 建置一个完善的邮件服务器

Postfix+ Courier-imap+Smtp

由于安装邮件服务器必须支持POP3+SMTP 这两个协议所以必须要安装Imap(POP3)。这里使用Courier-imap来启用POP3,如果已经安装了那可以跳过这步安装步骤,并接者安装cyrus-sasl(SMTP)最后开始设定Postfix 就可以完成整个安装与设定的步骤。

三、安装配置dns

具体这里不做描述

四、安装配置 Postfix mutt

Emerge是来源于Gentoo Linux的portage包管理系统的管理工具,portage体现了Gentoo Linux特有的理念。Red Hat是没有这个工具的。Red Hat 9甚至没有分源安装软件的概念,Emerge对他来说也是多余的。

#emerge postfix mutt

下面对 postfix 进行必要的配置,修改 /etc/postfix/main.cf 中如下内容:

#vi /etc/postfix/main.cf  

myhostname = $host.domain.name    //主机名.域名

  mydomain = $domain.name        // 这里填 域名

  inet_interfaces = all

  mydestination = $myhostname, localhost.$mydomain $mydomain

  mynetworks = my.ip.net.work/24, 127.0.0.0/8

  home_mailbox = .maildir/

  local_destination_concurrency_limit = 2

  default_destination_concurrency_limit = 10

修改 /etc/postfix/master.cf 如下:

#vi /etc/postfix/master.cf

# service type  private unpriv  chroot  wakeup  maxproc command + args

#               (yes)   (yes)   (yes)   (never) (50)

#

=========================================================

smtp      inet  n       -       n       -       -       smtpd -v

  // 只要在 smtpd 后面添加  -v

下面修改 /etc/mail/aliases 加入你的 alias,其中至少要有一个 root: your@email.address。

#/usr/bin/newaliases   // 让新的别名生效,每次添加修改别名后都要做这一步

#/etc/init.d/postfix start   // 启动 postfix 进程

#rc-update add postfix default    // 将 postfix 加入启动级

测试邮件系统是否运作正常

由 root 给你的系统其他用户(如user)发一封邮件

#mutt -x user

  Subject: check postfix   // 邮件主题

  (End message with a . on a line by itself)

  How are u?   输入邮件正文

.            键入一个 . 结束输入,发送邮件

以用户 user 登录,键入 mutt 会提示你 .maildir 不存在是否建立,键入 yes ,如果看到刚才 root 发来的邮件表示 postfix 运行正常。

五、安装配置 Courier-imap

#emerge courier-imap

对 Courier-imap 进行必要的配置

#cd /etc/courier-imap     

// 如果你要开启 courier-imap 或 pop3 的 ssl ,你要生成 cert 文件,

          // 如果你不想可以跳过下面一步。

#nano -w pop3d.cnf

#nano -w imapd.cnf     // 修改上述两个文件中的 C, ST, L, CN, 和 email 参数。

#mkpop3dcert

#mkimapdcert

启动 courier 相关服务

#/etc/init.d/courier-imapd start

#/etc/init.d/courier-imapd-ssl start

#/etc/init.d/courier-pop3d start

#/etc/init.d/courier-pop3d-ssl start

如果确定无误可以将上述服务加入启动级

#rc-update add courier-imapd default

#rc-update add courier-imapd-ssl default

#rc-update add courier-pop3d default

#rc-update add courier-pop3d-ssl default

六、安装配置 Fetchmail(可选)

#emerge fetchmail

#/etc/init.d/fetchmail start       // 启动 fetchmail 进程

#rc-update add fetchmail default   // 将 fetchmail 加入启动级

用 fetchmail 可以将你的远端 POP3 邮件服务器上的邮件收取到本地用户邮件中。配置 fetchmail,主要是配置/etc/fetchmailrc(这个文件如没有要手动建立) ,下面是一个例子。注意要把 fetchmailrc 的权限设为 700 ,不然你的帐户密码被人偷了别找我哦 ;-)

defaults

        proto pop3

        poll sina // 帐户名

        proto pop3   // POP3 协议

        via pop3.sina.com.cn   // 远端 POP3 服务器地址

        user "loginname"   // 用户名

        pass "password"   // 登录密码

        is localuser   // 收取邮件的本地用户名,邮件会收取到该用户的 ~/.maildir 邮箱中

        fetchall       // 不保留远端邮件复本

七、安装配置cyrus-sasl

# emerge cyrus-sasl

# nano -w /etc/sasl2/smtpd.conf

pwcheck_method:saslauthd       //我们使用 saslauthd 这个 daemon 来进行认证的工作

# rc-update add saslauthd default   //将 saslauthd 加入预设的启动的程序当中

再在/etc/postfix/main.cf中添加:

#vi /etc/postfix/main.cf    //表示开启SASL认证

smtpd_sasl_auth_enable = yes

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain =

smtpd_sasl_security_options = noanonymous

#/etc/init.d/postfix  restart   //重启一下postfix

检查一下端口:

#lsof –i:25   //如有以下信息,表端口已经起来

COMMAND   PID USER   FD   TYPE  DEVICE SIZE NODE NAME

master  23887 root   11u  IPv4 3312861       TCP *:smtp (LISTEN)

#lsof –i:110  //如有以下信息,表端口已经起来

COMMAND   PID USER   FD   TYPE  DEVICE SIZE NODE NAME

couriertc 922 root    5u  IPv4 3138285       TCP *:pop3 (LISTEN)

# telnet localhost 25     //检测验证

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

220 mail.zh.test.com ESMTP Postfix

ehlo localhost

250-mail.zh.test.com

250-PIPELINING

250-SIZE 2048000

250-VRFY

250-ETRN

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN    //有这些就表示启用了SASL认证

250 8BITMIME

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值