openpne メール設定

sakuraの専用サーバ(CentOS)を使っていて(最小構成)、
DNS管理はvalue-domainな構成のときのOpenPNEのメール設定の手順。

面倒くさそうだけど、手順どおりにやればDNS浸透(約10分)、作業(5分)くらいでできる。

value-domaindns設定

ログイン > DNSレコード/URL転送の変更 > (あなたのドメイン)

mx mail 10
a mail [IP]
txt mx v=spf1 a mx ip4:[IP]

openpne設定

config.phpを編集

define('MAIL_SERVER_DOMAIN', 'あなたのドメイン');
define('MAIL_DEBUG_LOG', true);

postfixインストール

sendmailを停止、標準メールサーバをpostfixに切り替え。

yum install postfix
/etc/init.d/sendmail stop

/usr/sbin/alternatives --config mta

There are 2 programs which provide 'mta'.

  Selection    Command
-----------------------------------------------
   1           /usr/sbin/sendmail.postfix
*+ 2           /usr/sbin/sendmail.sendmail

Enter to keep the current selection[+], or type selection number: 1

/sbin/chkconfig postfix  on

postfix設定

openpne用設定ファイル作成

vi /etc/postfix/virtual.openpne

/^get(@.*)?$/ openpne-request
/^p[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^t[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^b[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^bi[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^ci[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^ti[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^bc[0-9]+-[0-9a-z]{12}(@.*)?$/ openpne-request
/^blog(@.*)?$/ openpne-request
postfix設定ファイル編集

vi /etc/postfix/main.cf

myhostname = 設定したいドメイン
mydomain = 設定したいドメイン
myorigin = $mydomain
#inet_interfaces = localhost
inet_interfaces = all
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    reject_unauth_destination

message_size_limit = 10485760
virtual_alias_maps = pcre:/etc/postfix/virtual.openpne

openpne用リクエストメールアカウント作成

vi /etc/aliases

...
openpne-request: "|/usr/bin/php [openpneのpath]/bin/mail.php"
...

newaliases

postfix起動

/etc/init.d/postfix restart

動作確認

  • 携帯からメール新規登録できるか
  • 携帯からアクセスして日記が投稿できるか

おまけ:デバッグ

openpneのconfig.phpの中にメール受信時にvar/log/mail.logにログを吐くように設定できるので

define('MAIL_DEBUG_LOG', true);

有効にしてtailで受信できるかエラー内容などを確認しながらやる