mac Lionでローカルでpostfixを起動してローカルのメールボックスに保存してみる

メールをローカルのpostfixに送信して自分で受信してローカルのメールボックスに保存するテストをしてみる
$vim /etc/postfix/main.cf

myhostname = yuhsaku.co.jp    #ローカルのpostfixのホスト名を適当に設定
mydestination = $myhostname, localhost.$mydomain, localhost    #myhostnameのドメインできたメールは自分が宛先とする


sudo postfix start

telnet localhost 25
をすると反応がなくなってしまうので/var/log/mail.logを見ると

	fatal: open /etc/postfix/submit.cred: No such file or directory

みたいなエラーが出ている。



http://tohae.hatenablog.com/entry/20110929/1317278539
で対応が書いてあったので、そのとおりにファイルを作成して2行を追加してからパーミッションを設定する

$ sudo touch /etc/postfix/submit.cred
$ sudo vim /etc/postfix/submit.cred
#この2行を追加
submitcred version 1
hostname|username|password
$ sudo chmod 600 /etc/postfix/submit.cred


これでとりあえず
http://linux.kororo.jp/cont/server/postfix.php
に書いてある通り動作確認をする。

$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 yuhsaku.co.jp ESMTP Postfix

helo localhost
250 yuhsaku.co.jp

mail from:
250 2.1.0 Ok

rcpt to:
250 2.1.5 Ok

data
354 End data with .

subject:hoge test
way way
.
250 2.0.0 Ok: queued as A6BD7198621F

quit
221 2.0.0 Bye
Connection closed by foreign host.

すると、すぐに以下のようなメッセージがコンソールに出てくるので

You have new mail in /var/mail/A11068


中身を見てみるとちゃんとメールがローカルに保存されていました。
cat /var/mail/a11068

From ore@test.co.jp  Mon Aug 27 21:43:47 2012
Return-Path: 
X-Original-To: A11068@yuhsaku.co.jp
Delivered-To: A11068@yuhsaku.co.jp
Received: from localhost (localhost [IPv6:::1])
	by yuhsaku.co.jp (Postfix) with SMTP id A6BD7198621F
	for ; Mon, 27 Aug 2012 21:43:13 +0900 (JST)
subject:hoge test
Message-Id: <20120827124332.A6BD7198621F@yuhsaku.co.jp>
Date: Mon, 27 Aug 2012 21:43:13 +0900 (JST)
From: ore@test.co.jp

way way


※postfixのデフォルトのメール保存形式はmbox形式なんですね