LionでRailsからPostfixを使ってメール送信する際の注意点

blog.auxout.jp

だいたいこれの通り設定し、Lionの場合postfixはデフォルトでインストールされていたので、普通にsudo postfix startして、deliver!!!!!してみたもののメソッドの実行が終わらず、「なんか失敗したかな?」と思いながらちょっと待ったら、何のエラーも出ずに終了したので「成功したのかな?」と思ってメーラーの受信ボタンを連打してみるもなんにも届いておらず悲しんだ話。

postfixのログがどこにあるのかわからんかったけど、とりあえず/var/log/mail.logを見てみたらちゃんとエラーが出ていた

Sep 29 14:52:14 dhcp076 postfix/smtpd[37271]: fatal: open /etc/postfix/submit.cred: No such file or directory
Sep 29 14:52:15 dhcp076 postfix/master[37207]: warning: process /usr/libexec/postfix/smtpd pid 37271 exit status 1
Sep 29 14:52:15 dhcp076 postfix/master[37207]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

/etc/postfix/submit.credってファイルが無いらしい。確かに無い。
で、エラーメッセージでぐぐってみたらアップルのサポートコミュニティが出てきた。
Apple

英語で色々書かれてたけど特に読まず、

In order to fix the problem your console is displaying, you should:
1.Create a submit.cred file in /etc/postfix directory (sudo touch /etc/postfix/submit.cred will do).
2.Create a header for that file: sudo echo "submitcred version 1" >> /etc/postfix/submit.cred
3.Add as many lines as the number of users you want to enable to submit mail, in the form hostname|user|passwd sudo echo''hostname|username|password" >> /etc/postfix/submit.cred
4.Give the file the appropriate permissions: sudo chmod 600 /etc/postfix/submit.cred

この部分だけ見て実行してみた。

$ 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

このあとpostfixを再起動してみて、再度deliver!!!!!!したら無事に届いた。