ラベル Postfix の投稿を表示しています。 すべての投稿を表示
ラベル Postfix の投稿を表示しています。 すべての投稿を表示

2014年2月5日水曜日

Postfix2.10以降で発生するリレー接続エラー (454:Relay access denied)

554ではないRelay access denied

Postfixを2.9以前のバージョンから2.10以降のバージョンへ更新すると、 次のようなエラーが発生してリレー接続が出来なくなってしまう場合があるようです。
軽くハマったので残しておきます。(・ω・`)

said: 454 4.7.1 <xxxxxxx@xxxxxxxx.xxx>: Relay access denied (in reply to RCPT TO command)

どうやら2.10以降では、パラメータとデフォルト値などに少し変更があったようです。
以下はpostfix.orgのマニュアルから抜粋。

smtpd_relay_restrictions (default: permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination)

Access restrictions for mail relay control that the Postfix SMTP server applies in the context of the RCPT TO command, before smtpd_recipient_restrictions.

This feature is available in Postix 2.10 and later.

smtpd_relay_restrictions (RCPT TOコマンドの場面で適用するメールリレー用のアクセス制限設定)
2.9以前はsmtpd_recipient_restrictionsパラメータで設定されていたものが、このパラメータで設定するようになったとの事です。

取り敢えず、2.9以前のsmtpd_recipient_restrictionsパラメータのデフォルト値を確認してみました。

[root@localhost ~]# postconf smtpd_recipient_restrictions
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination

2.10以降ではsmtpd_relay_restrictions パラメータのデフォルト値は以下。
(下位互換の確保として、smtpd_recipient_restrictionsのパラメータ自体も使えはするみたいですが、でも値は空になっています。)

[root@localhost ~]# postconf smtpd_relay_restrictions 
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination 

[root@localhost ~]# postconf smtpd_recipient_restrictions
smtpd_recipient_restrictions =  

今回の場合では、アップデートによってpermit_sasl_authenticated値が追加された事で、SMTP:454の応答が返却されていたんですね。

2013年12月25日水曜日

Postfix 先頭がハイフンのメールアドレスにメールを送信出来ない

allow_min_userの値を変更する

デフォルトでpostfixは先頭がハイフン(-)のメールアドレス(RFC準拠)にメールを送信出来ないなんて知らず……。
先頭にハイフン文字を使ったドコモ宛のメールが大量に詰まってました。 (・ω・`)

invalid recipient syntax: \"-*******@docomo.ne.jp\"
(/var/log/maillog)

main.cfallow_min_user値を設定(デフォルト未設定)して、先頭がハイフン(-)のメールアドレスにもメールが送信されるようにしました。

# allow_min_user (デフォルト: no)
# 受信者アドレスが最初の文字として '-' を持つことを許可します。
# コマンドラインでEメールアドレスを渡すソフトウェアでの事故を避けるため、デフォルトではこれを認めません。
allow_min_user = yes

どういう事かと言うと、例えば「-*******@******.**.**」という先頭ハイフンなメールアドレスへ、コンソール上からmailコマンドを使って送信しようとした場合。

[root@localhost ~]# mail -s 'user unknown' -*******@******.**.**
mail: invalid option -- *
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

となっちゃうんです。

わたしの場合は規制する必要がないので制限を解除しました。 ヽ(´▽`*)ノ


bounce_queue_lifetimeの値を変更する

標準の設定では、maximal_backoff_timeに設定した時間の間隔で5日間(bounce_queue_lifetime)も再送し続けてしまうので、ついでにこの値も変更しておきました。
・変更前 5日
・変更後 3時間 (180分)

# bounce_queue_lifetime (デフォルト: 5d)
# 配送できないと見なすまでに、バウンスメッセージがキューに入っている最大の時間。
# デフォルトでは、通常のメールに対するキューの寿命と同じです。
# 時間単位: s (秒)、m (分)、h (時)、d (日)、w (週)。 デフォルトの時間単位は d (日) です。
# メール配送の試行を1回だけにするには 0 を指定します。
# この機能は Postfix 2.1 以降で使えます。
bounce_queue_lifetime = 180m

詳しくは、Postfix設定パラメータを読んで下さい。



[宣伝] Postfixの参考書です。

わたしも読みました!!

気になっている1冊です。

2013年12月23日月曜日

起動しないPostfix

fatal: bind 0.0.0.0 port 25: Address already in use

先日に続いてPostfixネタです。

postfix-2.10をインストールして起動しようとしたら
fatal: bind 0.0.0.0 port 25: Address already in use
なんてエラーが出ました。

[root@centos5.8 ~]# rpm -qa 'postfix'
postfix-2.10.2-1.el5

[root@centos5.8 ~]# alternatives --config mta

2 プログラムがあり 'mta' を提供します。

  選択       コマンド
-----------------------------------------------
*  1           /usr/sbin/sendmail.sendmail
 + 2           /usr/sbin/sendmail.postfix
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します: 2

[root@centos5.8 ~]# /etc/init.d/postfix start
postfix を起動中:                                          [失敗]

ログ(/var/log/maillog)を確認してみると……。

[root@centos5.8 ~]# tail -n 10 /var/log/maillog
Dec 24 23:59:59 centos5.8 postfix/postfix-script[17557]: starting the Postfix mail system
Dec 24 23:59:59 centos5.8 postfix/master[17559]: fatal: bind 0.0.0.0 port 25: Address already in use
Dec 24 23:59:59 centos5.8 postfix/master[17558]: fatal: daemon initialization failure
Dec 24 23:59:59 centos5.8 postfix/postfix-script[17560]: fatal: mail system startup failed

お前は既に使われている(port 25: Address already in use)って言ってる。
そうだった! sendmailを停止し忘れていました。(・_・;)

なので、sendmailを停止させてpostfixを再度起動ですね。

[root@centos5.8 ~]# /etc/init.d/sendmail stop
sendmail を停止中:                                         [成功]

[root@centos5.8 ~]# /etc/init.d/postfix start
postfix を起動中:                                          [成功]

無事起動出来ましたヽ(´∀`*)ノ すっかりヌケてました。

2013年12月22日日曜日

CentOS 5.8 最新版のPostfix 2.10をインストールする。

今回は最新版のPostfix(現時点ではpostfix-2.10.2-1.el5)を、yum, rpm, makeのそれぞれでインストールしてみました。


yumでインストール

今回は、最新版のPostfix(現時点では2.10.2)をインストールしてみました。
(リポジトリはCentALTを使いました。)

[root@localhost ~]# yum install --enablerepo=CentALT 'postfix'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

~中略~

Running Transaction
  Updating       : postfix                                                                                          1/2
  Cleanup        : postfix                                                                                          2/2

Updated:
  postfix.i686 2:2.10.2-1.el5

Complete!

ログ解析ツールのpflogsumm(postfix-perl-script)もインストールしました。
同じリポジトリからpostfix-perl-scriptsを指定してインストールでOKです。

[root@localhost ~]# yum install --enablerepo=CentALT 'postfix-perl-scripts'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

~中略~

Running Transaction
  Installing     : postfix-perl-scripts                                                                             1/1

Installed:
  postfix-perl-scripts.i686 2:2.10.2-1.el5

Complete!

pflogsummは、yesterday(昨日分)とtoday(本日分)しか集計することが出来ないんですね~。
日付指定とか出来れば便利かな?
集計可能な項目も含めて変更の余地がありそうですね!


rpmでインストール

こちらは後から別のマシンで行った作業ログです。
RPMパッケージは、CentALTにあるものを使わせて頂きました。
(インストール出来たパターン)

[root@centos5.8 ~]# rpm -Uvh http://centos.alt.ru/repository/centos/5/x86_64/postfix-2.10.2-1.el5.x86_64.rpm
準備中...                ########################################### [100%]
   1:postfix                ########################################### [100%]

[root@centos5.8 ~]# rpm -Uvh http://centos.alt.ru/repository/centos/5/x86_64/postfix-perl-scripts-2.10.2-1.el5.x86_64.rpm
http://centos.alt.ru/repository/centos/5/x86_64/postfix-perl-scripts-2.10.2-1.el5.x86_64.rpm を取得中
準備中...                ########################################### [100%]
   1:postfix-perl-scripts   ########################################### [100%]


rpmコマンドでのインストール中にエラーとなったマシンがありました。
(エラーが発生したパターン)

[root@localhost ~]# rpm -Uvh http://centos.alt.ru/repository/centos/5/x86_64/postfix-2.10.2-1.el5.x86_64.rpm
http://centos.alt.ru/repository/centos/5/x86_64/postfix-2.10.2-1.el5.x86_64.rpm を取得中
エラー: 依存性の欠如:
        libc.so.6()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libc.so.6(GLIBC_2.2.5)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libc.so.6(GLIBC_2.3)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libc.so.6(GLIBC_2.3.2)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libc.so.6(GLIBC_2.3.4)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libc.so.6(GLIBC_2.4)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libcrypto.so.6()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libdb-4.3.so()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libdl.so.2()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        liblber-2.3.so.0()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libldap-2.3.so.0()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libm.so.6()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libmysqlclient.so.15()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libmysqlclient.so.15(libmysqlclient_15)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libnsl.so.1()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libnsl.so.1(GLIBC_2.2.5)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libpcre.so.0()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libpq.so.4()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libresolv.so.2()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libresolv.so.2(GLIBC_2.2.5)(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libsasl2.so.2()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libssl.so.6()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています
        libz.so.1()(64bit) は postfix-2.10.2-1.el5.x86_64 に必要とされています

依存関係エラーが多数。 (・ω・`)
存在するはずのライブラリの依存エラーが表示されているので、以前に遭遇したコレと同じなのかな。 何なんだろう……。

取り敢えず、yumコマンドですんなり入りました。


makeでインストール

公式にあるpostfix-2.10.2.tar.gzをダウンロードして、ソースからインストールしてみました。

[root@localhost ~]# make
............. [準備中]

2013年11月28日木曜日

Ubuntu 12.x Postfixとmailコマンドのインストール

Postfixのインストール

下記の例では、apt-getコマンドを使用してPostfixをインストールしています。

root@Ubuntu12:~# apt-get install postfix
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  ssl-cert
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb mail-reader postfix-doc openssl-blacklist
The following NEW packages will be installed:
  postfix ssl-cert
0 upgraded, 2 newly installed, 0 to remove and 65 not upgraded.
Need to get 1,287 kB of archives.
After this operation, 3,278 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main ssl-cert all 1.0.28ubuntu0.1 [12.3 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main postfix i386 2.9.6-1~12.04.1 [1,274 kB]
Fetched 1,287 kB in 1s (1,021 kB/s)
Preconfiguring packages ...
~中略~
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.

Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
 * Stopping Postfix Mail Transport Agent postfix   [ OK ]
 * Starting Postfix Mail Transport Agent postfix   [ OK ]
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@Ubuntu12:~# /etc/init.d/postfix status
 * postfix is running

mailコマンドのインストール (mailutils)

root@Ubuntu12:~# mail -s "Mail Testing" user@ubuntu.xxx
The program 'mail' is currently not installed.  You can install it by typing:
apt-get install mailutils

標準では、mailコマンドが存在しないのでインストールします。
mailコマンドは、mailutilsから取得出来ます。
apt-getまたはaptitudeコマンドでインストールして下さい。

root@Ubuntu12:~# apt-get install mailutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  guile-1.8-libs libgsasl7 libltdl7 libmailutils2 libmysqlclient18 libntlm0 mysql-common
Suggested packages:
  mailutils-mh
The following NEW packages will be installed:
  guile-1.8-libs libgsasl7 libltdl7 libmailutils2 libmysqlclient18 libntlm0 mailutils mysql-common
0 upgraded, 8 newly installed, 0 to remove and 65 not upgraded.
Need to get 3,153 kB of archives.
After this operation, 11.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ precise/main libltdl7 i386 2.4.2-1ubuntu1 [38.1 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main mysql-common all 5.5.34-0ubuntu0.12.04.1 [13.3 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu/ precise-updates/main libmysqlclient18 i386 5.5.34-0ubuntu0.12.04.1 [922 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu/ precise/main guile-1.8-libs i386 1.8.8+1-6ubuntu2 [755 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu/ precise/universe libntlm0 i386 1.2-1 [18.4 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu/ precise/universe libgsasl7 i386 1.6.1-1 [133 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu/ precise/universe libmailutils2 i386 1:2.2+dfsg1-5 [872 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu/ precise/universe mailutils i386 1:2.2+dfsg1-5 [401 kB]
Fetched 3,153 kB in 2s (1,212 kB/s)
Selecting previously unselected package libltdl7.
(Reading database ... 51954 files and directories currently installed.)
Unpacking libltdl7 (from .../libltdl7_2.4.2-1ubuntu1_i386.deb) ...
Selecting previously unselected package mysql-common.
Unpacking mysql-common (from .../mysql-common_5.5.34-0ubuntu0.12.04.1_all.deb) ...
Selecting previously unselected package libmysqlclient18.
Unpacking libmysqlclient18 (from .../libmysqlclient18_5.5.34-0ubuntu0.12.04.1_i386.deb) ...
Selecting previously unselected package guile-1.8-libs.
Unpacking guile-1.8-libs (from .../guile-1.8-libs_1.8.8+1-6ubuntu2_i386.deb) ...
Selecting previously unselected package libntlm0.
Unpacking libntlm0 (from .../libntlm0_1.2-1_i386.deb) ...
Selecting previously unselected package libgsasl7.
Unpacking libgsasl7 (from .../libgsasl7_1.6.1-1_i386.deb) ...
Selecting previously unselected package libmailutils2.
Unpacking libmailutils2 (from .../libmailutils2_1%3a2.2+dfsg1-5_i386.deb) ...
Selecting previously unselected package mailutils.
Unpacking mailutils (from .../mailutils_1%3a2.2+dfsg1-5_i386.deb) ...
Processing triggers for man-db ...
Setting up libltdl7 (2.4.2-1ubuntu1) ...
Setting up mysql-common (5.5.34-0ubuntu0.12.04.1) ...
Setting up libmysqlclient18 (5.5.34-0ubuntu0.12.04.1) ...
Setting up guile-1.8-libs (1.8.8+1-6ubuntu2) ...
Setting up libntlm0 (1.2-1) ...
Setting up libgsasl7 (1.6.1-1) ...
Setting up libmailutils2 (1:2.2+dfsg1-5) ...
Setting up mailutils (1:2.2+dfsg1-5) ...
update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode.
update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode.
update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode.
update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode.
update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode.
update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode.
update-alternatives: using /usr/bin/mail.mailutils to provide /usr/bin/mailx (mailx) in auto mode.
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@Ubuntu12:~# mail -s 'Email Testing' user@ubuntu.xxx
Cc:
Null message body; hope that's ok