菜鸟学Linux 第060篇笔记 mail server概念,postfix 编译
Mail Server
TLS: Transport Layer Security
SMTP: Simple Mail Transfer Protocol
ESMTP: Extended Simple Mail Transfer Protocol
POP3: Post Office Protocol vertion 3
IMAP4: Internet Mail Access Protocol (消耗资源大,但功能也相对强)
UUCP: Unix to Unix CoPy
Unix 主机复制文件的协议
SMTP: (25/tcp)
C/S
邮件传输 MT (Mail Transfer)
邮件投递 MD (Mail Delivery)
邮件用户 MU (Mail User)
邮件用户代理 MUA (Mail User Agent)
邮件传输代理 MTA (Mail Transfer Agent)
邮件投递代理 MDA (Mail Delivery Agent)
邮件取回代理 MRA (Mail Retrieval Agent)
MUA 从 MRA 取邮件 用 POP3 or IMAP4
LMTP Local Mail Transfer Protocol
smtpd
SMTP Simple Mail Transfer Protocol
邮件传递过程
MUA --> smtp --> SMTPD --> smtp --> SMTPD --> MDA --> MUA
Open Relay: 开放式中继 (一般不允许中继)
SASL: Simple Authentication Secure Layer 简单认证安全层 协议
WebMail
LDAP: Lightweight Directory Access Protocol
是一个可以提供快速检索的协议,比mysql检索的速度快10倍
缺点 写的速度慢
虚拟用户 仅用于访问某服务的数字标识
用户: 字符串 凭证(加密存放)
组建软件
MTA 邮件传输代理 Mail Transfer Agent SMTP服务器 (实现的软件)
sendmail, uucp
单体结构, SUID, 配置文件语法不好理解(m4编写)
qmail
postfix 模块化设计,安全,跟sendmail兼容,效率高
exim
Exchange (Windows, 异步消息协作平台)
SASL: v2
cyrus-sasl(saslauthd) 框架
courier-authlib
MDA 邮件投递代理 Mail Delivery Agent
procmail (sendmail)
maildrop
MRA 邮件取回代理 Mail Retrieval Agent (pop3, imap4) 实现软件
cryus-imap
dovecot
MUA 邮件用户代理 Mail User Agent
Outlook Express, Outlook
Foxmail
Thunderbird
Evolution
mutt(文本界面)
WebMail
Openwebmail (perl)
Squirrelmail (php)
Extmail (Extman管理组件) (perl)
EOS(Extmail OS), CentOS
邮件服务器布署
Postfix + SASL (courier-authlib) 发邮件
Dovecot + MySQL 收邮件
Webmail: Extmail + Extman + httpd
postfix: rpm 包不支持虚拟用户
1. 布署postfix
# service sendmail stop
# chkconfig sendmail off
# rpm -e --nodeps sendmail
确保linux系统里已经安装了MySQL 前边章节有,这里不再详解其安装过程
# groupadd -g 2525 postfix
# useradd -g 2525 -u 2525 -M -s /sbin/nologin postfix
# groupadd -g 2526 postdrop
# useradd -g 2526 -u 2526 -M -s /sbin/nologin postdrop
# make makefiles 'CCARGS=-DASH_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH
-DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS '
'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2
-lsasl2 -lssl -lcrypto' (此为一行命令)
# make
# make install
启动postfix
# postfix start
postfix 配置文件:
postfix模块化:
master: /etc/postfix/master.cf
mail: /etc/postfix/main.cf
参数 = 值 (参数必须写在行的绝对行首,以空白开头的行被认为是上一行的延续)
postconf (Postfix configuration utility)
-d Print main.cf default parameter settings instead of
actual settings. Specify -df to fold long lines for
human readability (Postfix 2.9 and later).
-n Show only configuration parameters that have explicit
name=value settings in main.cf. Specify -nf to fold
long lines for human readability (Postfix 2.9 and
later).
-m List the names of all supported lookup table types. In
Postfix configuration files, lookup tables are specified
as type:name, where type is one of the types listed
below. The table name syntax depends on the lookup table
type as described in the DATABASE_README document.
-A List the available SASL client plug-in types. The SASL
plug-in type is selected with the smtp_sasl_type or
lmtp_sasl_type configuration parameters by specifying
one of the names listed below.
cyrus This client plug-in is available when Postfix is
built with Cyrus SASL support.
-e Edit the main.cf configuration file, and update parame-
ter settings with the "name=value" pairs on the post-
conf(1) command line.
smtp状态码
1xx 纯信息
2xx 正确
3xx 上一步操作尚未完成,需要继续补充
4xx 暂时性错误
5xx 永久性错误
smtp协议原语(命令)telnet localhost 25
helo (smtp协议) hostname
ehlo (esmtp协议) hostname
mail from: root
rcpt to (recipient 接受方)
data
.
alias: 邮件别名
abc@mysky.com: postmaster@mysky.com
/etc/aliases --> hash --> /etc/aliases.db
# newaliases
postfix默认把本机的IP地址所在的网段识别为本地网络,并且为之中继邮件;
本文转自Winthcloud博客51CTO博客,原文链接http://blog.51cto.com/winthcloud/1886015如需转载请自行联系原作者
Winthcloud