Postfix郵件系統

一、郵件服務器系統原理 

郵件系統中的角色

MUAMail User Agent ,郵件用戶代理

MTAMail Transfer Agent ,郵件傳輸代理

MDAMail Delivery Agent ,郵件投遞代理

郵件協議

郵件發送協議SMTP

Simple Mail Transfer Protocol ,簡單郵件傳輸協議

郵件收取協議

POP3 Post Office Protocol V3,郵局協議第3

IMAP4 Internet Message Access Protocol  V4,因特網消息訪問協議第4

 

二、Postfix郵件系統的架構 

 

三、安裝及配置Postfix郵件服務 

1,建立測試用戶

2,安裝postfix

yum -y install postfix wireshark

3,關閉sendmail

service sendmail stop

chkconfig sendmail on

 

alternatives --config mta      選擇使用哪個MTA來傳送郵件

 

4,開始啓動postfix

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

myhostname = station7.example.com

inet_interfaces = all

記住要註釋掉:inet_interfaces = localhost

mynetworks = 192.168.0.0/24 127.0.0.0/8  標註可以使用該郵件服務器的地址範圍。

 

[root@server1 ~]#service postfix restart

[root@server1 ~]#chkconfig postfix on

 

四、Postfix主要配置文件 

主配置文件:/etc/postfix/main.cf

[root@server1 ~]#grep  -v  "^#" /etc/postfix/main.cf

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

mail_owner = postfix

myhostname = server2.example.com

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost

unknown_local_recipient_reject_code = 550

mynetworks = 192.168.2.0/24, 127.0.0.0/8

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

debug_peer_level = 2

debugger_command =

         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

         xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix

newaliases_path = /usr/bin/newaliases.postfix

mailq_path = /usr/bin/mailq.postfix

setgid_group = postdrop

html_directory = no

manpage_directory = /usr/share/man

sample_directory = /usr/share/doc/postfix-2.3.3/samples

readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES

 

五、安裝及配置pop3服務

Dovecot Setup

1,install

[root@server1 ~]#yum -y install dovecot

2,配置時間和服務器一致,最好使用NTP,也可以使用date -s 年月日或date -s 時:分:秒

3,配置

[root@server1 ~]#vi /etc/dovecot.conf

#protocols = pop3 imap imaps pop3s

protocols =pop3 imap imaps pop3s

 

[root@server1 ~]#service dovecot start

[root@server1 ~]#chkconfig dovecot on

[root@server1 ~]#service iptables stop

測試:

[root@server1 ~]#echo "thist is a test "|mail -s "hello" [email protected]

[root@server1 ~]#mutt -f pops://[email protected]

 

六、使用cyrus-sasl增加SMTP認證 

SMTP認證的配置
安裝cyrus-sasl
1
、確認cyrus-sasl是否安裝了
[root@server1 ~]# rpm -qa|grep cyrus
cyrus-sasl-plain-2.1.22-4
cyrus-sasl-lib-2.1.22-4
cyrus-sasl-2.1.22-4

Cyrus-SASL V2
的密碼驗證機制
[root@server1 ~]# saslauthd -v
saslauthd 2.1.22
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
我們準備用的是shadow的密碼驗證機制。

[root@server1 ~]#vi /etc/sysconfig/saslauthd
MECH=shadow
啓動sasldaemon並測試:
[root@server1 ~]# service saslauthd start

開啓saslselinux布爾值

[root@server1 ~]#setenfoce      0
[root@server1 ~]# /usr/sbin/testsaslauthd -u
帳號 -p '密碼'
0: OK "Success."   =>
帳號驗證成功了
[root@server1 ~]# chkconfig saslauthd on

設置postfix啓用SMTP認證
[root@server1 ~]# vi /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain= ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,
           reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

 



wq!
保存

此外,由於當postfix要使用SMTP認證時,會讀取/usr/lib/sasl2/smtpd.conf文件的內容以確定所採用的認證方式,所以必須保證/usr/lib/sasl2/smtpd.conf文件的內容是:
pwcheck_method: saslauthd

 

測試:

沒有使用smtp驗證時

[root@server1 ~]# telnet 192.168.2.253 25

Trying 192.168.2.253...

Connected to server2.example.com (192.168.2.253).

Escape character is '^]'.

220 server2.example.com ESMTP Postfix

ehlo localhost

250-server2.example.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

 

使用了smtp驗證時:

[root@server1 ~]# telnet 192.168.2.253 25

Trying 192.168.2.253...

Connected to server2.example.com (192.168.2.253).

Escape character is '^]'.

220 server2.example.com ESMTP Postfix

ehlo localhost

250-server2.example.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

 

 

七、使用telnet測試smtppop3服務

使用telnet發送郵件

[root@server2 ~]# telnet 192.168.2.253 25

Trying 192.168.2.253...

Connected to server1.example.com (192.168.2.253).

Escape character is '^]'.

220 server1.example.com ESMTP Postfix

helo example.com

250 server1.example.com

mail from:<[email protected]>

250 2.1.0 Ok

rcpt to:<[email protected]>

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

hello!1211311

this is hello for ann

.

250 2.0.0 Ok: queued as EBE88F06C2

quit

221 2.0.0 Bye

Connection closed by foreign host.

[root@server2 ~]# mailq

Mail queue is empty

[root@server2 ~]# su - ann

[ann@server2 ~]$ mail

Mail version 8.1 6/6/93.  Type ? for help.

"/var/spool/mail/ann": 1 message 1 new

>N  1 [email protected]  Wed Aug 12 06:43  15/568 

& q

Held 1 message in /var/spool/mail/ann

 

使用telnet收郵件

[root@server2 ~]# telnet 192.168.2.253 110

Trying 192.168.2.253...

Connected to server1.example.com (192.168.2.253).

Escape character is '^]'.

+OK Dovecot ready.

user ann

+OK

pass ann

+OK Logged in.

quit

+OK Logging out.

Connection closed by foreign host.

 

八、設置郵件別名和羣組  [★]

郵件用戶別名

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

添加一行:

local        mate,tony

localhost:           mate

 

添加好以後使用命令:newaliases更新別名數據庫。

發送給local的郵件都轉發給matetony

發送給localhost的郵件都轉發給mate

 

 

九、設置郵箱空間大小和郵件大小限制  [★]

主配置文件參數:

#最大smtp併發進程數
default_process_limit = 1024
# 本地同時同址分發限制
local_destination_concurrency_limit = 50
# 同時同址分發限制
default_destination_concurrency_limit = 50
# 反垃圾郵件組織過濾
maps_rbl_domains = blackholes.mail-abuse.org
# 最大郵件的長度
message_size_limit = 52428800
# 最大郵箱大小
mailbox_size_limit = 524288000
# 彈回最大郵件的大小
bounce_size_limit = 52428800

 

十、安裝及配置SquirrelMail系統 

安裝:

[root@server2 ~]#yum  -y  install   squirrelmail

[root@server2 ~]#/usr/share/squirrelmail/config/conf.pl

 

輸入d,然後輸入cyrus(指定IMAP服務器類型)

輸入2. 選擇Server Settings然後輸入1修改Domainexample.com

                                  3修改Sendmail or SMTPSMTP

輸入4. 選擇General Options然後輸入5修改Usernames in Lowercase : true

輸入10 選擇Languages然後輸入1修改Default Language : zh_CN

最後輸入s保存以上修改,再輸入q退出(修改的文件同時保存在/etc/squirrelmail/config.php/usr/share/squirrelmail/config/config.php

 

瀏覽器中輸入http://服務器域名或IP/webmail.打開登陸頁面

 輸入用戶名和密碼(默認可以用系統存在的用戶名)

 

squirrelmail附件大小的設置方法
 
今天終於把squirrelmail的附件大小限制搞定了。主要方法是:修改php.ini
 cd /etc/php5/apache2/
 vi /php.ini
 max_execution_time=30 ;//
改爲600(增加處理腳本的時間限制)
 max_input_time=600 ;//
最大輸出時間600s
 memory_limit=8M ;//
改爲100M(這樣才能發送100M以下的附件)
 register_global=on ;//
個人認爲沒必要打開
 post_max_size=2M ;//php
可接收的post的大小
 file_uploads=on ;//
允許上傳文件
 upload_max_filesize=2M ;//
改爲100M
 session_auto_start=1 ;//seession
自動啓動(我沒改)
 
參考技術信息:
 
修改SquirrelMail 附件的大小到10M
 
如果您要修改SquirrelMail 附件的大小,需要直接修改 /etc/php5/apache2/php.ini 文件:
 memory_limit = 40M ; //
改爲40M (這樣才能發10M的附件)
 post_max_size = 10M ; //php
可接受的 post 方法大小 10M
 upload_max_filesize = 10M ; //
最大上載文件10M
 
如果使用Postfix 作爲後臺郵件服務器,還需要修改main.cf
 message_size_limit = 14336000 (
附件大小,14M,實際爲10M的文件)
 mailbox_limit = 102400000
(郵箱空間100M
 create_maildirsize = yes
 mailbox_extended = yes


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章