YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2024-03-20 (水)


[一語一絵/IT系]

postfixの忘れ物 / 2014-08-29 (金)

6月にTrusty化した「さくらのVPS」の自前サーバ。

新しい開発案件用にテストメールアカウントを作成し、外部から送信したところエラー発生。/var/log/mail.logをチェックしたところ

Aug 28 12:49:21 vps postfix/local[30170]: 21266220B29: to=<test-alert@bravotouring.com>, relay=local, delay=0.51, delays=0.44/0.01/0/0.06, dsn=5.3.0, status=bounced (command line usage error. Command output: /usr/lib/dovecot/deliver: invalid option -- 'n' Usage: dovecot-lda [-c <config file>] [-a <address>] [-d <username>] [-p <path>] [-f <envelope sender>] [-m <mailbox>] [-e] [-k] )
という事らしい。

言うに事欠いてinvalid optionって何よ?しかもpostfixじゃなくてdovecot-ldaですか?

という事で調べてみたところ、/etc/postfix/main.cfmailbox_commandの記述が問題らしい。dovecotのバージョンアップに追従できないらしく、/etc/dovecot/conf.d/01-dovecot-postfix.confも無くなっているので、

yano@vps:~$ diff /etc/postfix/main.cf.20140607 /etc/postfix/main.cf
75c75,76
< mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/conf.d/01-dovecot-postfix.conf -n -m "${EXTENSION}"
---
> # mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/conf.d/01-dovecot-postfix.conf -n -m "${EXTENSION}"
> mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/conf.d/15-lda.conf -m "${EXTENSION}"
…な感じで改修し、無事に送受信できるようになった。
Aug 28 13:52:45 vps postfix/smtpd[31583]: connect from relay.shared-server.net[211.13.204.74]
Aug 28 13:52:45 vps postfix/smtpd[31583]: EE2A2220C89: client=relay.shared-server.net[211.13.204.74]
Aug 28 13:52:45 vps postfix/cleanup[31590]: EE2A2220C89: message-id=<62CFC27BDBFD84test-sender@nalab.jp>
Aug 28 13:52:45 vps postfix/qmgr[31398]: EE2A2220C89: from=<test-sender@nalab.jp>, size=1704, nrcpt=1 (queue active)
Aug 28 13:52:45 vps postfix/smtpd[31583]: disconnect from relay.shared-server.net[211.13.204.74]
Aug 28 13:52:46 vps dovecot: lda(test): msgid=<62CFC27BDBFD84test-sender@nalab.jp>: save failed to open mailbox alert: Mailbox doesn't exist: alert
Aug 28 13:52:46 vps dovecot: lda(test): msgid=<62CFC27BDBFD84test-sender@nalab.jp>: saved mail to INBOX
Aug 28 13:52:46 vps postfix/local[31591]: EE2A2220C89: to=<test-alert@bravotouring.com>, relay=local, delay=0.1, delays=0.07/0/0/0.03, dsn=2.0.0, status=sent (delivered to command: /usr/lib/dovecot/deliver -c /etc/dovecot/conf.d/15-lda.conf -m "${EXTENSION}")
Aug 28 13:52:46 vps postfix/qmgr[31398]: EE2A2220C89: removed

/var/log/mail.logに残っていたMailbox doesn't existという気になるメッセージは/etc/dovecot/conf.d/15-lda.confrecipient_delimiter/etc/postfix/main.cfと同様'-'に変更すればいい。

yano@vps:~$ diff -bc /etc/dovecot/conf.d/15-lda.conf.orig /etc/dovecot/conf.d/15-lda.conf
*** /etc/dovecot/conf.d/15-lda.conf.orig        2014-05-15 03:11:09.000000000 +0900
--- /etc/dovecot/conf.d/15-lda.conf     2014-08-28 15:32:53.215650617 +0900
***************
*** 30,35 ****
--- 30,36 ----

  # Delimiter character between local-part and detail in email address.
  #recipient_delimiter = +
+ recipient_delimiter = -

  # Header where the original recipient address (SMTP's RCPT TO: address) is taken
  # from if not available elsewhere. With dovecot-lda -a parameter overrides this.
…とわかったのだが、そもそも他のアカウント宛では出てこないdovecotが動いている事自体がおかしいので、もう一度整理してみた。

…と、dovecotが動いてたのは~/.forwardprocmail経由のMaildir配送が機能していなかったせいだ。

という事にやっと気付いて

yano@vps:~$ cat ~test/.forward
"|exec /usr/bin/procmail -f- || exit 75"
として万事OK。
Aug 28 16:12:19 vps postfix/smtpd[950]: connect from relay.shared-server.net[211.13.204.71]
Aug 28 16:12:19 vps postfix/smtpd[950]: DD25B220C89: client=relay.shared-server.net[211.13.204.71]
Aug 28 16:12:19 vps postfix/cleanup[1017]: DD25B220C89: message-id=<8ACFC28F5B5A7Btest-sender@nalab.jp>
Aug 28 16:12:19 vps postfix/qmgr[506]: DD25B220C89: from=<test-sender@nalab.jp>, size=1703, nrcpt=1 (queue active)
Aug 28 16:12:19 vps postfix/smtpd[950]: disconnect from relay.shared-server.net[211.13.204.71]
Aug 28 16:12:19 vps postfix/local[1018]: DD25B220C89: to=<test-alert@bravotouring.com>, relay=local, delay=0.12, delays=0.09/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to command: exec /usr/bin/procmail -f- || exit 75)
Aug 28 16:12:19 vps postfix/qmgr[506]: DD25B220C89: removed

【参照】
●Postfixのぺーじ http://www.postfix-jp.info/
Postfix で知らないローカルユーザを拒否する