环境: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!!到此结束