构建电子邮件系统(MTAMDA MUA

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

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

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

尚观之webmail搭建笔记

实验环境

IP地址:192.168.6.1/24

主机名: mail.uplooking.com

邮件域:@uplooking.com

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

使用dovecot提供收信服务

域名设置

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

[[email protected] ~]# tar zxvfpostfix-2.4.6.tar.gz

[[email protected] ~]# gunzippostfix-2.4.6-vda-ng.patch.gz

[[email protected] ~]# cd postfix-2.4.6

[[email protected] 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服务

[[email protected] ~]# 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/ //邮件存储位置和格式

[[email protected] ~]#postfix reload

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

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

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

[email protected] ~]# 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,可插拔认证模块)进行身份认证,以便识别并验证系统用户,通过认证的用户才允许从邮箱中收取邮件

[[email protected] ~]# vi/etc/pam.d/dovecot

auth requiredpam_nologin.so

auth include system-auth

account includesystem-auth

session includesystem-auth

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

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

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

启动dovecot服务

[[email protected] ~]# /usr/local/sbin/dovecot-c /etc/dovecot.conf

[[email protected] ~]# netstat -anptl | grepdovecot

安装客户端程序

[[email protected] ~]# tar jxvfsquirrelmail-1.4.13.tar.bz2 -C/usr/local/apache2/htdocs/

[[email protected] ~]# cd/usr/local/apache2/htdocs/

[[email protected] htdocs]# mvsquirrelmail-1.4.13 webmail

[[email protected] htdocs]# cd webmail

[[email protected] webmail]# tar jxvf~/zh_CN-1.4.13-20071220.tar.bz2

[[email protected] webmail]# mkdir -pattach data

[[email protected] webmail]# chown -Rdaemon:daemon attach/ data/

[[email protected] webmail]# chmod 730attach/

[[email protected] webmail]# cpconfig/config_default.phpconfig/config.php

[[email protected] 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 服务

[[email protected] ~]# cd /usr/lib/sasl2/

[[email protected] sasl2]# cp Sendmail.confsmtpd.conf

[[email protected] sasl2]# vi /usr/lib/sasl2/smtpd.conf

pwcheck_method: saslauthd

[[email protected] sasl2]# service saslauthdstart

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

[[email protected] ~]# 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 //若收件人地址未在授权网络内,则拒绝发送


设置别名实现群发

[[email protected] ~]# vi/etc/postfix/main.cf

alias_maps = hash:/etc/aliases

[[email protected] ~]# vi /etc/aliases

student: zhangsan, lisi, mike, john

[[email protected] ~]# newaliases


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

相关文章:

  • 2022-12-23
  • 2022-01-24
  • 2021-11-10
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-09-29
猜你喜欢
  • 2021-05-18
  • 2021-10-16
  • 2021-11-13
  • 2021-09-02
  • 2021-05-26
  • 2021-08-04
  • 2022-12-23
相关资源
相似解决方案