Postfix

postfixWietseVenemaIBMGPL协议之下开发的MTA(邮件传输代理)软件。postfixWietseVenema想要为使用最广泛的sendmail提供替代品的一个尝试。在Internet世界中,大部分的电子邮件都是通过sendmail来投递的,大约有100万用户使用sendmail,每天投递上亿封邮件。这真是一个让人吃惊的数字。Postfix试图更快、更容易管理、更安全,同时还与sendmail保持足够的兼容性。

特点

  免费

  postfix想要作用的范围是广大的Internet用户,试图影响大多数的Internet上的电子邮件系统,因此它是免费的。

  更快

  postfix在性能上大约比sendmail×××倍。一部运行postfix的台式PC每天可以收发上百万封邮件。

  兼容性好

  postfix是sendmail兼容的,从而使sendmail用户可以很方便地迁移到postfix。Postfix支持/var【/spool】/mail、/etc/aliases、NIS、和~/.forward文件。

  更健壮

  postfix被设计成在重负荷之下仍然可以正常工作。当系统运行超出了可用的内存或磁盘空间时,postfix会自动减少运行进程的数目。当处理的邮件数目增长时,postfix运行的进程不会跟着增加。

  更灵活

  postfix是由超过一打的小程序组成的,每个程序完成特定的功能。可以通过配置文件设置每个程序的运行参数。

  安全性

  postfix具有多层防御结构,可以有效地抵御恶意***者。如大多数的postfix程序可以运行在较低的权限之下,不可以通过网络访问安全性相关的本地投递程序等等。

邮件队列(mailqueues)

  postfix有四种不同的邮件队列,并且由队列管理进程统一进行管理:

  1.maildrop:本地邮件放置在maildrop中,同时也被拷贝到incoming中。

  2.incoming:放置正在到达或队列管理进程尚未发现的邮件。

  3.active:放置队列管理进程已经打开了并正准备投递的邮件,该队列有长度的限制。

  4.deferred:放置不能被投递的邮件。

  队列管理进程仅仅在内存中保留active队列,并且对该队列的长度进行限制,这样做的目的是为了避免进程运行内存超过系统的可用内存。

模块的管理文件/etc/postfix/master.cf

postfix主配置文档/etc/postfix/main.cf

指令postconf-d默认参数

-n新参数

-e编辑

postconf-e“参数”

一:地址验证

1【本地域名mydomain=a.com

2【本地主机名称myhostname=mail.a.com

3【邮件地址伪装】myorigin=$mydomain

4【确定监听地址inet_interfaces=all

5确定本地信件】mydestination=$myhostname,localhost.$mydomain,localhost,$mydomain

6设置中继,基于地址】mynetworks=192.168.20.0/24,127.0.0.0/8

登录到本地地址发送邮件:

Trying192.168.20.100...

Connectedto192.168.20.100(192.168.20.100).

Escapecharacteris'^]'.

220a.comESMTPPostfix

ehlomail.a.com

250-a.com

250-PIPELINING

250-SIZE10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250DSN

mailfrom:[email protected]

2502.1.0Ok

rcptto:[email protected]

2502.1.5Ok

data

354Enddatawith<CR><LF>.<CR><LF>

subject:ok

adjshjk

.

2502.0.0Ok:queuedas03EABFFA4E

quit

可以发送邮件但是没有身份验证

二:.账号验证

broken_sasl_auth_clients=yes

smtpd_sasl_auth_enable=yes

smtpd_sasl_security_options=noanonymous

#smtpd_sasl_application_name=smtpd

#smtpd_client_restrictions=permit_sasl_authenticated,reject

#smtpd_client_restrictions=permit_sasl_authenticated

smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

servicepostfixrestart

[root@localhostServer]#telnet192.168.20.10025

Trying192.168.20.100...

Connectedto192.168.20.100(192.168.20.100).

Escapecharacteris'^]'.

220a.comESMTPPostfix

ehlomail.a.com

250-a.com

250-PIPELINING

250-SIZE10240000

250-VRFY

250-ETRN

250-AUTHPLAINLOGIN验证的信息

250-AUTH=PLAINLOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250DSN

虽然设置验证机制,默认是不进行强制验证,任何人都还是可以发

[root@localhostServer]#telnet192.168.20.10025

Trying192.168.20.100...

Connectedto192.168.20.100(192.168.20.100).

Escapecharacteris'^]'.

220a.comESMTPPostfix

mailfrom:[email protected]

2502.1.0Ok

rcptto:[email protected]

2502.1.5Ok

data

开启验证服务,servicesaslauthdstart

并且打开smtpd_client_restrictions=permit_sasl_authenticated,reject

禁掉smtpd_client_restrictions=permit_sasl_authenticated

broken_sasl_auth_clients=yes

smtpd_sasl_auth_enable=yes

smtpd_sasl_security_options=noanonymous

#smtpd_sasl_application_name=smtpd

smtpd_client_restrictions=permit_sasl_authenticated,reject

#smtpd_client_restrictions=permit_sasl_authenticated

smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

再次发送邮件客户端主机被拒绝发信

[root@localhostServer]#telnet192.168.20.10025

Trying192.168.20.100...

Connectedto192.168.20.100(192.168.20.100).

Escapecharacteris'^]'.

220a.comESMTPPostfix

mailfrom:[email protected]

2502.1.0Ok

rcptto:[email protected]

5545.7.1<unknown[192.168.20.100]>:Clienthostrejected:Accessdenied

如果能通过验证,不是本地地址的邮件也可以往外发,在配置文件里去掉192.168.20.0这个网段的地址,打开postfix的配置文件

mynetworks=127.0.0.0/8

[root@localhost~]#echo-n"[email protected]"|opensslbase64

dXNlcjFAYS5jb20=

[root@localhost~]#echo-n"123"|opensslbase64

MTIz

[root@localhostServer]#telnet192.168.20.10025

Trying192.168.20.100...

Connectedto192.168.20.100(192.168.20.100).

Escapecharacteris'^]'.

220a.comESMTPPostfix

authlogindXNlcjFAYS5jb20=

334UGFzc3dvcmQ6

MTIz

2352.0.0Authenticationsuccessful

mailfrom:[email protected]

2502.1.0Ok

rcptto:[email protected]

2502.1.5Ok