尚观之webmail搭建笔记

构建电子邮件系统(MTA MDA  MUA

Postfix:提供邮件发送服务(SMTP)

Dovecot:提供邮件收取服务(POP3)

squirrelmail:用于收发信的客户端工具

 

 

 

实验环境

IP地址:192.168.6.1/24

主机名:  mail.uplooking.com

邮件域:@uplooking.com

邮件帐号:使用本地系统用户

使用dovecot提供收信服务

域名设置

需要在 uplooking.com域的DNS服务器中注册,设置相应的A记录和MX记录

[root@mail ~]# tar zxvfpostfix-2.4.6.tar.gz

[root@mail ~]# gunzippostfix-2.4.6-vda-ng.patch.gz

[root@mail ~]# cd postfix-2.4.6

[root@mail postfix-2.4.6]# patch  -p1 < ../postfix-2.4.6-vda-ng.patch

 

配置文件目录:/etc/postfix/

服务程序目录:/usr/libexec/postfix/

邮件队列目录:/var/spool/postfix/

 

1)incoming传入:刚接收到的邮件   

2)active活动:正在投递的邮件   

3)deferred推迟:以前投递失败的邮件

4)hold约束:被阻止发送的邮件   

5)corrupt错误:不可读或不可分析的邮件

 

邮件管理程序目录:/usr/sbin/

1)postalias:用于构造、修改和查询别名表   

2)postmap:用于构造、修改或者查询查询表

3)postconf:用于显示和编辑main.cf配置文件   

4)postfix用于启动、停止postix,要求root用户权限

5)postqueue:用于管理邮件队列,一般用户使用   

6)postsuper:用于管理邮件队列,要求有root用户权限

/var/log/maillog  //记录了postfix服务的邮件传递等过程信息

/etc/postfix/master.cf    //master主程序的配置文件

/etc/postfix/main.cf     //postfix服务的配置文件

 

Postfix服务控制

使用/usr/sbin/postfix程序

常见控制参数:start、stop、reload、check

“start”、“stop”、“check”、“reload”参数分别用于启动、停止、检查、重载postfix服务

 

[root@mail ~]# vi/etc/postfix/main.cf

inet_interfaces =192.168.6.1, 127.0.0.1      

myhostname =mail.uplooking.com            

mydomain =uplooking.com                   

myorigin =$mydomain   //外发邮件时 发件人地址中的的域名               

mydestination =$mydomain, $myhostname   //允许投递到本地的邮件域名

home_mailbox =Maildir/  //邮件存储位置和格式

[root@mail ~]#postfix  reload

 

postfix支持2种最常见的邮箱存储方式

 

Mailbox:将同一用户的所有邮件内容存储在同一个文件中,例如 “/var/spool/mail/username”,这种方式比较古老,在邮件数量较多时查询和管理的效率较低

Maildir:使用目录结构来存储用户的邮件内容,每一个用户对应有一个文件夹,每一封邮件作为一个独立的文件保存,例如/home/username/Maildir/*。这种方式存取速度和效率更好,而且对于邮件内容管理也更方便

root@mail ~]# vi/etc/dovecot.conf

……

ssl_disable =yes  //禁用SSL机制

……

protocols = pop3 imap  //支持的邮局协议

……

disable_plaintext_auth= no //允许明文密码认证

……

mail_location =maildir:~/Maildir  //邮件存储格式及位置

 

 

创建PAM认证文件

Dovecot使用PAM方式(Pluggable Authentication Module,可插拔认证模块)进行身份认证,以便识别并验证系统用户,通过认证的用户才允许从邮箱中收取邮件

[root@mail ~]# vi/etc/pam.d/dovecot

auth       required    pam_nologin.so

auth       include      system-auth

account    include     system-auth

session    include     system-auth

 

 —— auth、account、session分别表示登录身份认证、帐号属性认证、登陆中的会话认证(打开文件、挂载设备等资源)

    —— required 表示此行记录中的认证必须通过,否则即认为认证失败

    —— include 表示包含其他文件中的认证配置(system-auth对应为/etc/pam.d/system-auth文件)

 

启动dovecot服务

[root@mail ~]# /usr/local/sbin/dovecot-c /etc/dovecot.conf

[root@mail ~]# netstat -anptl | grepdovecot

 

安装客户端程序

[root@mail ~]# tar  jxvf squirrelmail-1.4.13.tar.bz2  -C/usr/local/apache2/htdocs/

[root@mail ~]# cd/usr/local/apache2/htdocs/

[root@mail htdocs]# mvsquirrelmail-1.4.13  webmail

[root@mail htdocs]# cd webmail

[root@mail webmail]# tar jxvf~/zh_CN-1.4.13-20071220.tar.bz2

[root@mail webmail]# mkdir  -p attach  data

[root@mail webmail]# chown  -R daemon:daemon  attach/  data/

[root@mail webmail]# chmod  730 attach/

[root@mail webmail]# cpconfig/config_default.php config/config.php

[root@mail webmail]# viconfig/config.php

$squirrelmail_default_language ='zh_CN';

$default_charset       = 'zh_CN.UTF-8';

$domain                 = 'benet.com';

$smtpServerAddress = 'localhost';

$smtpPort = 25;

$imap_server_type    = 'dovecot';

$imapPort = 143;

$data_dir                 ='/usr/local/apache2/htdocs/webmail/data/';

$attachment_dir      ='/usr/local/apache2/htdocs/webmail/attach/';

 

SMTP用户认证流程

结合Cyrus SASL软件来实现

Simple Authentication and Security Layer

.配置并启动saslauthd服务

建立配置文件:/usr/lib/sasl2/smtpd.conf

启动 saslauthd 服务

[root@mail ~]# cd  /usr/lib/sasl2/

[root@mail sasl2]# cp  Sendmail.conf smtpd.conf

[root@mail sasl2]# vi  /usr/lib/sasl2/smtpd.conf

pwcheck_method: saslauthd

[root@mail sasl2]# service  saslauthd start

2. 调整 main.cf 文件,以便支持认证修改后要重载postfix服务:postfix reload

[root@mail ~]# vi /etc/postfix/main.cf

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

mynetworks = 127.0.0.1

smtpd_recipient_restrictions =     //设置收件人地址过滤规则

 permit_mynetworks,          //允许IP为mynetworks的客户使用本邮件系统寄出邮件

 permit_sasl_authenticated,     //允许通过SMTP认证的用户向外发送邮件

 reject_unauth_destination  //若收件人地址未在授权网络内,则拒绝发送


 

设置别名实现群发

[root@localhost ~]# vi/etc/postfix/main.cf

alias_maps = hash:/etc/aliases

[root@mail ~]# vi /etc/aliases

student: zhangsan, lisi, mike, john

[root@mail ~]# newaliases


安装包见及安装步骤:http://download.csdn.net/detail/gzh0222/4782188

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值