環境:RHEL 6.0
要求:
1要求可以遠程接收郵件
2默認投遞爲/var/spool/mail/userX
3發送給admin的郵件被user3接收
首先修改主配置文件/var/postfix/main.cf
75行:myhostname = mail.example.com //主機名
83行:ydomain = example.com //域名
99行:myorigin = $mydomain //僞裝
113行:inet_interfaces = all //默認只監聽本機端口,關閉那行關閉這行
164行:mydestination = $myhostname, localhost.$mydomain, example.com //把example.com加上
現在啓動服務(service postfix restart)的話就可以實現一個簡單的郵件發送了,
但還是不能實現遠程郵件的發送和接收,就必須配置dovecot
安裝包:rpm -ivh dovecot-*
接下來咱們就配置dovecot:
root@mail ~]# cd /etc/dovecot/
[root@mail dovecot]# vim dovecot.conf
25行:protocols = imap pop3 lmtp //指定支持的郵局協議
[root@mail conf.d]# vim 10-auth.conf
第9行:disable_plaintext_auth = no //允許明文密碼認證
第25行: mail_location = mbox:~/mail:INBOX=/var/mail/%u 設置郵件存儲位置
第6行:ssl = no //禁用ssl機制
啓動服務:service dovecot restart
測試:
[root@mail conf.d]# telnet mail.example.com 25 //發信測試
Trying ::1...
Connected to mail.example.com.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix
helo localhost
250 mail.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>
this is a test mail!
.
250 2.0.0 Ok: queued as 5FAD668BC4
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@mail conf.d]# telnet 192.168.0.10 110 //收信測試
Trying 192.168.0.10...
Connected to 192.168.0.10.
Escape character is '^]'.
+OK Dovecot ready. <[email protected]>
user user4
+OK
pass 123456
+OK Logged in.
list
+OK 8 messages:
1 539
2 420
3 444
4 459
5 524
6 261
7 264
8 460
.
retr 8
+OK 460 octets
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from localhost (mail.example.com [IPv6:::1])
by mail.example.com (Postfix) with SMTP id 5FAD668BC4
for <[email protected]>; Thu, 8 Dec 2011 00:36:53 +0800 (CST)
Message-Id: <[email protected]>
Date: Thu, 8 Dec 2011 00:36:53 +0800 (CST)
From: [email protected]
To: undisclosed-recipients:;
this is a test mail!
.
檢查/var/spool/mail/user4
[root@mail conf.d]# tail -10 /var/spool/mail/user4
for <[email protected]>; Thu, 8 Dec 2011 00:36:53 +0800 (CST)
Message-Id: <[email protected]>
Date: Thu, 8 Dec 2011 00:36:53 +0800 (CST)
From: [email protected]
To: undisclosed-recipients:;
X-UID: 8
Status: RO
this is a test mail!
別名:
[root@mail conf.d]# vim /etc/aliases
admin: user3 //添加到最後一行
[root@mail conf.d]# newaliases //刷新下別名文件
測試:
[root@mail conf.d]# mail [email protected]
Subject: 888888888888888888888888888
.
EOT
Null message body; hope that's ok
[root@mail conf.d]# su - user3
[user3@mail ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/user3": 3 messages 1 new 3 unread
U 1 root Thu Dec 8 00:53 19/592 "opt"
U 2 root Thu Dec 8 00:53 19/580 "opt"
>N 3 root Thu Dec 8 00:53 18/587 "888888888888888888888"
&
OK!!到此結束