Ubuntu13.10 下Postfix 邮件服务器安装及基本的设置
1.安装Postfix
apt-get install postfix
在安装的过程中,会提示输入选择类型和域名。
2.安装mailx软件包
apt-get install mailutils
mailx软件包是一个命令行的邮件属性程序,mail命令包含在mailx软件包里面
二,测试你的默认设置
1.添加测试用户(以s为例)
useradd -m -s /bin/bash s
passwd s
这里密码设置为123456。在后述的测试中会用到。
2.用下面的命令测试,其实就是测试25端口是否打开
telnet localhost 25
3.Postfix将在终端中显示如下提示,这样你就可以用来键入SMTP命令.
- root@ubuntu :~# telnet localhost 25
- Trying 127.0.0.1...
- Connected to localhost.
- Escape character is ‘^]‘.
- 220 ubuntu ESMTP Postfix (Ubuntu)
Trying 127.0.0.1...
Connected to localhost.
Escape character is ‘^]‘.
220 ubuntu ESMTP Postfix (Ubuntu)
ehlo localhost //
250-ubuntu
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: root@localhost //
250 2.1.0 Ok
rcpt to: fmaster@localhost //
250 2.1.5 Ok
data //
354 End data with .
Subject: My first mail on Postfix //
this ia the first postfix mail . //
. //
250 2.0.0 Ok: queued as 661C75F796
quit //
221 2.0.0 Bye
Connection closed by foreign host.
root@ubuntu :~# su - fmaster
fmaster@ubuntu:~$ mail
"/var/mail/fmaster": 1 message 1 new
>N 1 root@localhost 火 1月 29 12: 12/435 My first mail on Postfix
此时的邮件存放在/var/mail/fmaster文件中。
当这个邮件被打开之后,Postfix就会以mbox的风格处理邮件,
将邮件都保存到/home/fmaster/mbox这一个文件中。
6.设置Postfix以支持Maildir风格的邮箱(在修改配置之前备份配置文件)
- cp -pf /etc/postfix/main.cf /etc/postfix/main.cf_bak
- vim /etc/postfix/main.cf
- home_mailbox=Maildir/
- /etc/init.d/postfix restart
- root@ubuntu:/etc/postfix# telnet localhost 25
- Trying 127.0.0.1...
- Connected to localhost.
- Escape character is ‘^]‘.
- 220 ubuntu ESMTP Postfix (Ubuntu)
- ehlo localhost //
- 250-ubuntu
- 250-PIPELINING
- 250-SIZE 10240000
- 250-VRFY
- 250-ETRN
- 250-STARTTLS
- 250-ENHANCEDSTATUSCODES
- 250-8BITMIME
- 250 DSN
- mail from: root@localhost //
- 250 2.1.0 Ok
- rcpt to: fmaster@localhost //
- 250 2.1.5 Ok
- data //
- 354 End data with .
- Subject: maildir test //
- this is a maildir style mail test . //
- . //
- 250 2.0.0 Ok: queued as 249315F80D
- quit //
- 221 2.0.0 Bye
- Connection closed by foreign host.
- fmaster@ubuntu:~$ ll /home/fmaster/Maildir
- 合計 20
- drwx------ 5 fmaster fmaster 4096 1月 29 12:35 ./
- drwxr-xr-x 3 fmaster fmaster 4096 1月 29 12:35 ../
- drwx------ 2 fmaster fmaster 4096 1月 29 12:35 cur/
- drwx------ 2 fmaster fmaster 4096 1月 29 12:35 new/
- drwx------ 2 fmaster fmaster 4096 1月 29 12:35 tmp/
- fmaster@ubuntu:~/Maildir$ cd new
- fmaster@ubuntu:~/Maildir/new$ ll
- 合計 12
- drwx------ 2 fmaster fmaster 4096 1月 29 12:35 ./
- drwx------ 5 fmaster fmaster 4096 1月 29 12:35 ../
- -rw------- 1 fmaster fmaster 426 1月 29 12:35 1359430545.Vfc00I16daM671946.ubuntu
- fmaster@ubuntu:~/Maildir/new$ less 1359430545.Vfc00I16daM671946.ubuntu
- Return-Path:
- X-Original-To: fmaster@localhost
- Delivered-To: fmaster@localhost
- Received: from localhost (localhost [127.0.0.1])
- by ubuntu (Postfix) with ESMTP id 249315F80D
- for ; Tue, 29 Jan 2013 12:35:13 +0900 (JST)
- Subject: maildir test
- Message-Id: <20130129033517.249315F80D@ubuntu>
- Date: Tue, 29 Jan 2013 12:35:13 +0900 (JST)
- From: root@localhost
- this is a maildir style mail test .
- 1359430545.Vfc00I16daM671946.ubuntu (END)
在配置收信服务器中,需要使用到域名,如果没有域名可以修改hosts文件来进行测试。
下面配置中用到的域名: dotuian.com
邮件服务器的IP地址
测试客户端 : 192.168.0.80 (windows 7)
三,配置收信服务器
1.修改邮件服务器的hosts文件
- vim /etc/hosts
- 127.0.0.1 dotuian.com
以管理员权限运行一个文本编辑器,打开"C:\Windows\System32\drivers\etc\hosts",在里面添加
- 192.168.0.114 dotuian.com
3.安装收信服务器
- apt-get install courier-pop
- apt-get install courier-imap
- vim /etc/postfix/main.cf
- mydestination = localhost, ubuntu, localhost.localdomain, localhost, dotuian.com
- mynetworks = 192.168.0.0/24, 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
- #inet_interfaces = loopback-only
- inet_interfaces = all
5.重启postfix服务器
- /etc/init.d/postfix restart
- root@ubuntu:/etc/postfix# telnet dotuian.com 25
- Trying 127.0.0.1...
- Connected to dotuian.com.
- Escape character is ‘^]‘.
- 220 ubuntu ESMTP Postfix (Ubuntu)
- ehlo dotuian.com //
- 250-ubuntu
- 250-PIPELINING
- 250-SIZE 10240000
- 250-VRFY
- 250-ETRN
- 250-STARTTLS
- 250-ENHANCEDSTATUSCODES
- 250-8BITMIME
- 250 DSN
- mail from: [email protected] //
- 250 2.1.0 Ok
- rcpt to: [email protected] //
- 250 2.1.5 Ok
- data //
- 354 End data with .
- Subject: mail test with domain //
- this is a test mail . //
- dotuian.com //
- .
- 250 2.0.0 Ok: queued as 9E95D5F809
- quit //
- 221 2.0.0 Bye
- Connection closed by foreign host.
- fmaster@ubuntu:~/Maildir/new$ ll
- 合計 16
- drwx------ 2 fmaster fmaster 4096 1月 29 14:10 ./
- drwx------ 5 fmaster fmaster 4096 1月 29 12:35 ../
- -rw------- 1 fmaster fmaster 426 1月 29 12:35 1359430545.Vfc00I16daM671946.ubuntu
- -rw------- 1 fmaster fmaster 446 1月 29 14:10 1359436215.Vfc00I16d8M538132.ubuntu
- fmaster@ubuntu:~/Maildir/new$ less 1359436215.Vfc00I16d8M538132.ubuntu
- Return-Path:
- X-Original-To: [email protected]
- Delivered-To: [email protected]
- Received: from dotuian.com (localhost [127.0.0.1])
- by ubuntu (Postfix) with ESMTP id 9E95D5F809
- for ; Tue, 29 Jan 2013 14:09:35 +0900 (JST)
- Subject: mail test with domain
- Message-Id: <20130129050947.9E95D5F809@ubuntu>
- Date: Tue, 29 Jan 2013 14:09:35 +0900 (JST)
- From: [email protected]
- this is a test mail .
- dotuian.com
- 1359436215.Vfc00I16d8M538132.ubuntu (END)
- root@ubuntu:/etc/postfix# telnet dotuian.com 110
- Trying 127.0.0.1...
- Connected to dotuian.com.
- Escape character is ‘^]‘.
- +OK Hello there.
- user fmaster //
- +OK Password required.
- pass test1234 //
- +OK logged in.
- quit //
- +OK Bye-bye.
- Connection closed by foreign host.
- root@ubuntu:/etc/postfix# telnet dotuian.com 143
- Trying 127.0.0.1...
- Connected to dotuian.com.
- Escape character is ‘^]‘.
- * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information.
- a login fmaster test1234 //
- a OK LOGIN Ok.
- a logout //
- * BYE Courier-IMAP server shutting down
- a OK LOGOUT completed
- Connection closed by foreign host.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。