| 導購 | 订阅 | 在线投稿
分享
 
 
 

簡易安裝postfix郵件服務器

來源:互聯網  2008-05-31 00:04:52  評論

postfix郵件服務器(debian sarge)1、簡要說明

簡易安裝postfix郵件服務器

2.1、mail:~#apt-get install postfix

安裝,根據提示選"Internet Site"

Where should mail for root go填postfix

Mail name?填mail.wjjennluen.com

Other destinations to accept mail for?(blank for none)填mail.wjjennluen.com, localhost.wjjennleun.com, ,localhost

Force synchronous updates on mail queue?選否

2.2、檢查postfix服務是不是已經運行

mail:~# netstat -ln|grep 25

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

tcp6 0 0 :::25 :::* LISTEN

unix 2 [ ACC ] STREAM LISTENING 20256 /tmp/.ICE-unix/11772

2.3、測試postfix

mail:~# telnet 127.0.0.1 25

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)

ehlo mail

250-mail.wjjennluen.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250 8BITMIME

mail from: "This is a test mail!"

250 Ok

rcpt to:

250 Ok

data

354 End data with .

This is a test mail!

.

250 Ok: queued as 4888ACA0060

quit

221 Bye

Connection closed by foreign host.

好象是發出去了噢

2.4、檢查剛發的郵件是否收到

mail:~#apt-get install mailx下載mail閱讀器

mail:~# su - wxt

wxt@mail~:$ mail

No mail for wxt

wxt@mail:~$exit

mail:~#:

my god,沒有郵件啊

mail~:#more /var/mail/wxt

沒有

mail~:#more /var/spool/mail/wxt

沒有

咱回事呢

mail:~# telnet 127.0.0.1 25

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)

ehlo mail

250-mail.wjjennluen.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250 8BITMIME

mail from: "abc"

250 Ok

rcpt to:

250 Ok

data

354 End data with .

abc

.

250 Ok: queued as 609D0CA00BB

quit

221 Bye

Connection closed by foreign host.

mail:~# more /var/mail/wxt

From wxt@mail.wjjennluen.com Sat Jul 2 18:33:56 2005

Return-Path:

X-Original-To: wxt

Delivered-To: wxt@mail.wjjennluen.com

Received: from mail (localhost.localdomain [127.0.0.1])

by mail.wjjennluen.com (Postfix) with ESMTP id 609D0CA00BB

for ; Sat, 2 Jul 2005 18:33:42 +0800 (CST)

Message-Id:

Date: Sat, 2 Jul 2005 18:33:42 +0800 (CST)

From: wxt@mail.wjjennluen.com

To: undisclosed-recipients:;

abc

mail:~#

收到了,此時postfix工作在127.0.0.1上的,也就是localhost

查看mydestination參數的設定

mail:~# postconf |grep mydestination

mydestination = mail.wjjennluen.com, localhost.wjjennluen.com, , localhost

沒有wjjennleun.com,所以用wxt@wjjennluen.com發信,postfix不會接受,所以要添加wjjennluen.com給mydestination

mail:~# postconf |grep mydestination

mydestination = mail.wjjennluen.com wjjennluen.com localhost.wjjennluen.com localhost

現在就可以收到了

mail:~#/var/mail/wxt

mail:~# telnet 127.0.0.1 25

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)

ehlo mail

250-mail.wjjennluen.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250 8BITMIME

mail from: "abc"

250 Ok

rcpt to:

250 Ok

data

354 End data with .

abc

.

250 Ok: queued as 609D0CA00BB

quit

221 Bye

Connection closed by foreign host.

mail:~# more /var/mail/wxt

From wxt@mail.wjjennluen.com Sat Jul 2 18:33:56 2005

Return-Path:

X-Original-To: wxt

Delivered-To: wxt@mail.wjjennluen.com

Received: from mail (localhost.localdomain [127.0.0.1])

by mail.wjjennluen.com (Postfix) with ESMTP id 609D0CA00BB

for ; Sat, 2 Jul 2005 18:33:42 +0800 (CST)

Message-Id:

Date: Sat, 2 Jul 2005 18:33:42 +0800 (CST)

From: wxt@mail.wjjennluen.com

To: undisclosed-recipients:;

abc

mail:~#

2.5、安裝pop3,imap

mail:~#apt-get install courier-pop courier-imap

注意/etc/courier/pop3d配置文件

注意/etc/courier/imapd配置文件

用outlook測試pop3和imap成功

2.6、安裝apache,php,squirrelmail

mail:~#apt-get apache php4 php4-common squirrelmail

修改/etc/apache/httpd.conf

加入PHP支持

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

新建文件/var/www/test.php

phpinfo();

?

在浏覽器地址欄內輸入http://192.168.0.15/test.php

可以確定PHP是否可以正常工作

2.7、從mailbox 更改爲maildir

修改/etc/postfix/main.cf

增加參數設置

home_mailbox = Maildir/

更改mailbox_command 參數爲

mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/

新增

MAILDIR=$HOME/Maildir

mail:~#cd /home/wxt/

mail:~#maildirmake Maildir

mail:~#chmod -R 750 Maildir

mail:~#ln -s /usr/share/squirrelmail /var/www/squirrelmail

修改/usr/share/squirrelmail/config/conf.pl內的變量$auto_create_special = ture;,讓squirrelmail自動增加三個子目錄

添加webmail虛擬主機(基于名子)

打開/etc/apache/httpd.conf

添加虛擬主機配置參數

NameVirtualHost 192.168.0.15

ServerAdmin root@localhost

DocumentRoot /var/www/squirrelmail

ServerName webmail.wjjennluen.com

ErrorLog /var/log/apache/webmail/error.log

mail:~#makdir /var/log/apache/webmail

mail:~#touch /var/log/apache/webmail/error.log

注意在named配置文件裏面加入webmail.wjjennluen.com的記錄

在浏覽器的地址欄內輸入webmail.wjjennluen.com就可以登陸webmail了

2.7、給postfix 加上smtp 認證

mail:~# apt-get install postfix-tls sasl2-bin libsasl2-modules

修改/etc/default/saslauthd文件,設定START = yes

修改/etc/postfix/sasl/smtpd.conf,設定saslauthd來認證smtp

mail:~#mkdir /etc/postfix/sasl

mail:~#echo "pwcheck_method: saslauthd" /etc/postfix/sasl/smtpd.con

添加帳戶postfix到sasl組

mail:~#addgroup postfix sasl

修改/etc/postfix/main.cf, 使postfix使用sasl來實現smtp驗證功能

#=====sasl======#

smtpd_sasl_auth_enable = yes

broken_sasl_auth_clients = yes

smtpd_sasl_security_options = noanonymous

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, check_relay_domains, reject_unauth_destination

smtpd_client_restrictions = permit_sasl_authenticated

修改/etc/postfix/master.cf,讓postfix不要以chroot啓動,參數-v可以用來debug,正式上線爲了不使大量的log,一定要拿掉

# ==============================================

# service type private unpriv chroot wakeup maxproc command + args

# (yes) (yes) (yes) (never) (100)

# ==============================================

smtp inet n - n - - smtpd -v

重新啓動sasl 驗證程序

mail:~# /etc/init.d/saslauthd restart

重新啓動postfix

mail:~#/etc/init.d/postfix restart

mail:~# testsaslauthd -u wxt -p wxt

0: OK "Success."

測試sasl驗證程序可以正常工作了

postfix郵件服務器(debian sarge)  1、簡要說明   簡易安裝postfix郵件服務器   2.1、mail:~#apt-get install postfix   安裝,根據提示選"Internet Site"   Where should mail for root go填postfix   Mail name?填mail.wjjennluen.com   Other destinations to accept mail for?(blank for none)填mail.wjjennluen.com, localhost.wjjennleun.com, ,localhost   Force synchronous updates on mail queue?選否   2.2、檢查postfix服務是不是已經運行   mail:~# netstat -ln|grep 25   tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN   tcp6 0 0 :::25 :::* LISTEN   unix 2 [ ACC ] STREAM LISTENING 20256 /tmp/.ICE-unix/11772   2.3、測試postfix   mail:~# telnet 127.0.0.1 25   Trying 127.0.0.1...   Connected to 127.0.0.1.   Escape character is '^]'.   220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)   ehlo mail   250-mail.wjjennluen.com   250-PIPELINING   250-SIZE 10240000   250-VRFY   250-ETRN   250 8BITMIME   mail from: "This is a test mail!"   250 Ok   rcpt to:   250 Ok   data   354 End data with .   This is a test mail!   .   250 Ok: queued as 4888ACA0060   quit   221 Bye   Connection closed by foreign host.   好象是發出去了噢   2.4、檢查剛發的郵件是否收到   mail:~#apt-get install mailx   下載mail閱讀器   mail:~# su - wxt   wxt@mail~:$ mail   No mail for wxt   wxt@mail:~$exit   mail:~#:   my god,沒有郵件啊   mail~:#more /var/mail/wxt   沒有   mail~:#more /var/spool/mail/wxt   沒有   咱回事呢   mail:~# telnet 127.0.0.1 25   Trying 127.0.0.1...   Connected to 127.0.0.1.   Escape character is '^]'.   220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)   ehlo mail   250-mail.wjjennluen.com   250-PIPELINING   250-SIZE 10240000   250-VRFY   250-ETRN   250 8BITMIME   mail from: "abc"   250 Ok   rcpt to:   250 Ok   data   354 End data with .   abc   .   250 Ok: queued as 609D0CA00BB   quit   221 Bye   Connection closed by foreign host.   mail:~# more /var/mail/wxt   From wxt@mail.wjjennluen.com Sat Jul 2 18:33:56 2005   Return-Path:   X-Original-To: wxt   Delivered-To: wxt@mail.wjjennluen.com   Received: from mail (localhost.localdomain [127.0.0.1])   by mail.wjjennluen.com (Postfix) with ESMTP id 609D0CA00BB   for ; Sat, 2 Jul 2005 18:33:42 +0800 (CST)   Message-Id:   Date: Sat, 2 Jul 2005 18:33:42 +0800 (CST)   From: wxt@mail.wjjennluen.com   To: undisclosed-recipients:;   abc   mail:~#   收到了,此時postfix工作在127.0.0.1上的,也就是localhost   查看mydestination參數的設定    mail:~# postconf |grep mydestination   mydestination = mail.wjjennluen.com, localhost.wjjennluen.com, , localhost   沒有wjjennleun.com,所以用wxt@wjjennluen.com發信,postfix不會接受,所以要添加wjjennluen.com給mydestination   mail:~# postconf |grep mydestination   mydestination = mail.wjjennluen.com wjjennluen.com localhost.wjjennluen.com localhost   現在就可以收到了   mail:~#/var/mail/wxt   mail:~# telnet 127.0.0.1 25   Trying 127.0.0.1...   Connected to 127.0.0.1.   Escape character is '^]'.   220 mail.wjjennluen.com ESMTP Postfix (Debian/GNU)   ehlo mail   250-mail.wjjennluen.com   250-PIPELINING   250-SIZE 10240000   250-VRFY   250-ETRN   250 8BITMIME   mail from: "abc"   250 Ok   rcpt to:   250 Ok   data   354 End data with .   abc   .   250 Ok: queued as 609D0CA00BB   quit   221 Bye   Connection closed by foreign host.   mail:~# more /var/mail/wxt   From wxt@mail.wjjennluen.com Sat Jul 2 18:33:56 2005   Return-Path:   X-Original-To: wxt   Delivered-To: wxt@mail.wjjennluen.com   Received: from mail (localhost.localdomain [127.0.0.1])   by mail.wjjennluen.com (Postfix) with ESMTP id 609D0CA00BB   for ; Sat, 2 Jul 2005 18:33:42 +0800 (CST)   Message-Id:   Date: Sat, 2 Jul 2005 18:33:42 +0800 (CST)   From: wxt@mail.wjjennluen.com   To: undisclosed-recipients:;    abc    mail:~#      2.5、安裝pop3,imap   mail:~#apt-get install courier-pop courier-imap   注意/etc/courier/pop3d配置文件   注意/etc/courier/imapd配置文件   用outlook測試pop3和imap成功   2.6、安裝apache,php,squirrelmail   mail:~#apt-get apache php4 php4-common squirrelmail   修改/etc/apache/httpd.conf   加入PHP支持   AddType application/x-httpd-php .php   AddType application/x-httpd-php-source .phps   新建文件/var/www/test.php      phpinfo();   ?   在浏覽器地址欄內輸入http://192.168.0.15/test.php   可以確定PHP是否可以正常工作   2.7、從mailbox 更改爲maildir   修改/etc/postfix/main.cf   增加參數設置   home_mailbox = Maildir/   更改mailbox_command 參數爲   mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/   新增   MAILDIR=$HOME/Maildir   mail:~#cd /home/wxt/   mail:~#maildirmake Maildir   mail:~#chmod -R 750 Maildir   mail:~#ln -s /usr/share/squirrelmail /var/www/squirrelmail   修改/usr/share/squirrelmail/config/conf.pl內的變量$auto_create_special = ture;,讓squirrelmail自動增加三個子目錄   添加webmail虛擬主機(基于名子)   打開/etc/apache/httpd.conf   添加虛擬主機配置參數   NameVirtualHost 192.168.0.15      ServerAdmin root@localhost   DocumentRoot /var/www/squirrelmail   ServerName webmail.wjjennluen.com   ErrorLog /var/log/apache/webmail/error.log      mail:~#makdir /var/log/apache/webmail   mail:~#touch /var/log/apache/webmail/error.log   注意在named配置文件裏面加入webmail.wjjennluen.com的記錄   在浏覽器的地址欄內輸入webmail.wjjennluen.com就可以登陸webmail了   2.7、給postfix 加上smtp 認證   mail:~# apt-get install postfix-tls sasl2-bin libsasl2-modules   修改/etc/default/saslauthd文件,設定START = yes   修改/etc/postfix/sasl/smtpd.conf,設定saslauthd來認證smtp   mail:~#mkdir /etc/postfix/sasl   mail:~#echo "pwcheck_method: saslauthd" /etc/postfix/sasl/smtpd.con   添加帳戶postfix到sasl組   mail:~#addgroup postfix sasl   修改/etc/postfix/main.cf, 使postfix使用sasl來實現smtp驗證功能   #=====sasl======#   smtpd_sasl_auth_enable = yes   broken_sasl_auth_clients = yes   smtpd_sasl_security_options = noanonymous   smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, check_relay_domains, reject_unauth_destination   smtpd_client_restrictions = permit_sasl_authenticated   修改/etc/postfix/master.cf,讓postfix不要以chroot啓動,參數-v可以用來debug,正式上線爲了不使大量的log,一定要拿掉   # ==============================================   # service type private unpriv chroot wakeup maxproc command + args   # (yes) (yes) (yes) (never) (100)   # ==============================================   smtp inet n - n - - smtpd -v   重新啓動sasl 驗證程序   mail:~# /etc/init.d/saslauthd restart   重新啓動postfix   mail:~#/etc/init.d/postfix restart   mail:~# testsaslauthd -u wxt -p wxt   0: OK "Success."   測試sasl驗證程序可以正常工作了
󰈣󰈤
王朝萬家燈火計劃
期待原創作者加盟
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
王朝網路微信公眾號
微信掃碼關註本站公眾號 wangchaonetcn
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有