LoginSignup
1
1

More than 5 years have passed since last update.

Plesk 12.5 × CentOS 7.2 × Postfix でメール受信ができないバグ?

Last updated at Posted at 2017-04-20

発生した現象

  • メールの送信はできるが受信ができない。
  • Webメール(roundcube)から送信ができない。
  • 同じサーバ内(ローカル)からのメールは受信できる。
  • Pleskの「サービス管理」で「SMTPサーバ(Postfix)」が起動ステータスにならない。※「Dovecot IMAP および POP3 サーバ」や「Plesk メールフィルタ(Postfix)」は起動ステータスになっている。コマンドでステータスを確認するとpostfixは起動中になっている。
  • メールログを見ても外部からの受信の記録がない。
  • メールキューはとくに溜まっていない。
  • ファイアウォールはデフォルトのまま(全開放)。
  • ドメインDNSの設定に誤りはない。

実施したこと

hostname の修正

メールログ /var/log/maillog を確認すると warning: do not list domain localhost.localdomain in BOTH mydestination and virtual_mailbox_domains というエラーが出ていたので、以下を実施した。

mydestinationを空に

/etc/postfix/main.cf
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination =

修正したらpostfixを再起動。

systemctl restart postfix.service

Plesk からフルホスト名を修正

Plesk > ツールと設定 > サーバ設定 > フルホスト名
localhost.localdomain になっていたのでドメイン名に修正。
ひょっとしたら mydestination の修正は不要で、こっちだけでよかったのかも。

hostname の修正をし、エラーは出なくなったものの、現象は変わらず。

centos 7 のパーミッションバグ修正

postfix とは関係ないとは思うが、/var/log/messages に以下のエラーが出ていたので修正。

/var/log/messages
localhost systemd: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Please remove executable permission bits. Proceeding anyway.
localhost systemd: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executable. Please remove executable permission bits. Proceeding anyway.

パーミッション修正

chmod 0644 /usr/lib/systemd/system/wpa_supplicant.service
chmod 0644 /usr/lib/systemd/system/ebtables.service

参照
https://bugs.centos.org/view.php?id=10656
https://www.svennd.be/systemd-configuration-file-is-marked-executable-please-remove-executable-permission-bits-proceeding-anyway/

現象は変わらず。

最大接続数の修正

メールログに以下のエラーが時々出ていた。

/var/log/maillog
localhost postfix/anvil[3071]: statistics: max connection rate 1/60s for (submission:xxx.xx.xx.xxx) at Apr 19 19:24:33
localhost postfix/anvil[3071]: statistics: max connection count 1 for (submission:xxx.xx.xx.xxx) at Apr 19 19:24:33
localhost postfix/anvil[3071]: statistics: max cache size 1 at Apr 19 19:24:33

1つのドメインに約 150 のメールアカウントがあり、ひょっとすると同じIPアドレスから大量にクライアントが接続している可能性があるなと思ったので最大接続数を修正。

Plesk > ツールと設定 > メールサーバ設定 > IP アドレスあたりの 1 ユーザの最大接続数
10 ⇒ 300 に修正。
※この設定をするとスパマーから大量にメールを送れるようになってしまうので、同時に同じ画面の「送信メールメッセージ数の上限を設定する」で制限を設定した方がいいと思う。

依然としてメール受信できない。

25番ポート開放

外部サーバからメールを送信し、そのログを見てみると以下の記録があった。

/var/log/maillog
relay=none, delay=2288, delays=2288/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to xxxxxxx.com[xxx.xxx.xxx.xxx]:25: Connection refused)

25番ポートがつながらないようなのでつながるように修正。
Webメール(roundcube)もデフォルトでは25番ポートを使うようなので、修正すれば送れるようになる。

/etc/postfix/master.cf の修正

/etc/postfix/master.cf
# 以下を任意の場所に追記
153.122.115.173:25 inet n - n - - smtpd  # 外部からのメール受信用
localhost:25 inet n - n - - smtpd        # Webメール送信用

修正したらpostfixを再起動。

systemctl restart postfix.service

参考
https://talk.plesk.com/threads/webmail-not-working-after-switch-from-qmail-to-postfix.340255/
https://support.plesk.com/hc/en-us/articles/213937845

Webメールの送信ポート変更

上記の修正をすれば送信できるようになるので、これは任意。

/usr/share/psa-roundcube/config/defaults.inc.php
// ----------------------------------
// SMTP
// ----------------------------------

// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = 'localhost';

// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))
//$config['smtp_port'] = 25;
// Webメールの送信ポートを587に変更
$config['smtp_port'] = 587;

まとめ

25番ポート開放によりメール受信できるようになり、Webメールからの送信もできるようになりました。
昨日の時点ではPleskの「サービス管理」では相変わらず「SMTPサーバ(Postfix)」が起動ステータスになっていなかったのですが、今朝になって見てみると起動ステータスに変わっていました。

一応送受信できるようにはなりましたが、対応が適切かどうか自信がないので、誤りがありましたらご指摘いただけると幸いです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1