Postfix のインストール

Debian LS-AVL/A

LS-AVL をサーバとして育てていく。その3

メールが受け取れるように、 メールサーバとしてセットアップする。
ここはドメインマスタとして設定しているが、 あくまで想定ということで。
実際 yamasita.jp のドメインマスタは別にあるし。

今インストールされている MTA は

確か、exim4 がインストールされているはず。
root@av:~# dpkg -l | grep exim
root@av:~#
インストールされていない。。。

postfix のインストール

さすがに、もう sendmail は なさそうなので。
root@av:~# apt-get install postfix
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin
  resolvconf postfix-cdb mail-reader ufw
The following NEW packages will be installed:
  postfix
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1339 kB of archives.
After this operation, 3133 kB of additional disk space will be used.
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main postfix armel 2.7.1-1+squeeze1 [1339 kB]
Fetched 1339 kB in 1s (1250 kB/s)
  lqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqk
  x Please select the mail server configuration type that best meets your   x
  x needs.                                                                  x
  x                                                                         x
  x  No configuration:                                                      x
  x   Should be chosen to leave the current configuration unchanged.        x
  x  Internet site:                                                         x
  x   Mail is sent and received directly using SMTP.                        x
  x  Internet with smarthost:                                               x
  x   Mail is received directly using SMTP or by running a utility such     x
  x   as fetchmail. Outgoing mail is sent using a smarthost.                x
  x  Satellite system:                                                      x
  x   All mail is sent to another machine, called a 'smarthost', for        x
  x delivery.                                                               x
  x  Local only:                                                            x
  x   The only delivered mail is the mail for local users. There is no      x
  x network.                                                                x
  x                                                                         x
  x General type of mail configuration:                                     x
  x                                                                         x
  x                         No configuration                                x
  x                         Internet Site                                   x
  x                         Internet with smarthost                         x
  x                         Satellite system                                x
  x                         Local only                                      x
  x                                                                         x
  x                                                                         x
  x                                                             x
  x                                                                         x
  mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Internet Site を選択
 lqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqk
 x The "mail name" is the domain name used to "qualify" _ALL_ mail           x
 x addresses without a domain name. This includes mail to and from :   x
 x please do not make your machine send out mail from root@example.org       x
 x unless root@example.org has told you to.                                  x
 x                                                                           x
 x This name will also be used by other programs. It should be the single,   x
 x fully qualified domain name (FQDN).                                       x
 x                                                                           x
 x Thus, if a mail address on the local host is foo@example.org, the         x
 x correct value for this option would be example.org.                       x
 x                                                                           x
 x System mail name:                                                         x
 x                                                                           x
 x yamaista.jp______________________________________________________________ x
 x                                                                           x
 x                                                               x
 x                                                                           x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Unpacking postfix (from .../postfix_2.7.1-1+squeeze1_armel.deb) ...
Processing triggers for man-db ...
Setting up postfix (2.7.1-1+squeeze1) ...
Adding group `postfix' (GID 107) ...
Done.
Adding system user `postfix' (UID 103) ...
Adding new user `postfix' (UID 103) with group `postfix' ...
Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (GID 108) ...
Done.
setting myhostname: av
setting alias maps
setting alias database
setting myorigin
setting destinations: yamaista.jp, av, localhost.localdomain, localhost
setting relayhost:
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all

Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
Stopping Postfix Mail Transport Agent: postfix.
Starting Postfix Mail Transport Agent: postfix.
!root@av:~#

postfix の設定

/etc/postfix/main.cf をざっと見て、、、 受信できるドメインと、受信できるホストとを修正する。
root@av:~# cd /etc/postfix/
root@av:/etc/postfix# mv main.cf main.cf.orig
root@av:/etc/postfix# cp main.cf.orig main.cf
root@av:/etc/postfix# vi main.cf

root@av:/etc/postfix# diff -c main.cf.orig main.cf
*** main.cf.orig        Thu Jan 26 22:57:28 2012
--- main.cf     Thu Jan 26 23:06:11 2012
***************
*** 31,39 ****
  alias_maps = hash:/etc/aliases
  alias_database = hash:/etc/aliases
  myorigin = /etc/mailname
! mydestination = yamaista.jp, av, localhost.localdomain, localhost
  relayhost =
! mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  mailbox_size_limit = 0
  recipient_delimiter = +
  inet_interfaces = all
--- 31,39 ----
  alias_maps = hash:/etc/aliases
  alias_database = hash:/etc/aliases
  myorigin = /etc/mailname
! mydestination = yamaista.jp, av.yamasita.jp, localhost.localdomain, localhost
  relayhost =
! mynetworks = 127.0.0.0/8 192.168.0.0/16 [::ffff:127.0.0.0]/104 [::1]/128
  mailbox_size_limit = 0
  recipient_delimiter = +
  inet_interfaces = all
root@av:/etc/postfix#

/etc/aliases のコピー

他のマシンで使っている /etc/aliases をコピー。newaliases を実行
root@av:/etc/postfix# newaliases
root@av:/etc/postfix#
メールサーバとしては、これぐらいか

おっと。main.cf の再読み込み。

root@av:/etc/postfix# /etc/init.d/postfix restart
Stopping Postfix Mail Transport Agent: postfix.
Starting Postfix Mail Transport Agent: postfix.
root@av:/etc/postfix#

テスト

root@av:/etc/postfix# mail yasunari@yamasita.jp
Subject: test
mail
EOT
root@av:/etc/postfix# cat /var/spool/mail/yasunari
root@av:/etc/postfix#
ん?
root@av:/etc/postfix# cat /var/log/mail.log
	:
	:
Jan 26 23:20:43 av postfix/pickup[18640]: D7389C02DB7: uid=0 from=
Jan 26 23:20:43 av postfix/cleanup[18750]: D7389C02DB7: message-id=<20120126142043.D7389C02DB7@av>
Jan 26 23:20:43 av postfix/qmgr[18641]: D7389C02DB7: from=, size=399, nrcpt=1 (queue active)
Jan 26 23:20:44 av postfix/smtp[18752]: D7389C02DB7: to=, relay=ns.yamasita.jp[192.168.1.2]:25, delay=0.5, delays=0.04/0/0.42/0.04, dsn=2.0.0, status=sent (250 2.0.0 q0QEKh6k018635 Message accepted for delivery)
Jan 26 23:20:44 av postfix/qmgr[18641]: D7389C02DB7: removed
root@av:/etc/postfix#
あちゃぁ。MX に従って既存のサーバへ送ってる。まぁ、そうか。

ほかもテストする。

ゴニョゴニョ

うーん。
Postfix って /etc/aliases での
name: value
の value として、\ で展開を抑制(例:\name)って使えないの???

もうちょっと勉強しよう




LS-AVL/A
楽天市場
Amazon
uWorks
ValuMore
Yahoo!ショッピング


リモートバックアップ
ハックの記録
LinkStation/玄箱 をハックしよう

Debian の Postfix では、gmail を迷惑メールフィルタに使えない???

Copyright (C) 2003-2011 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市