配色:                          文字サイズ: 

POPFileでメールの仕分け 2/3

先日の記事”さくらメールの仕分け”の続きになります。

常時Windowsを起動されているのでしたら、Windows版の方が楽です。
こちらからWindows版をダウンロードしてインストールしてください。
http://getpopfile.org/download/

今回は自宅にある常時起動のストレージサーバへの、インストール手順を記録していきます。
CentOS 6.10(Linux)

[web@localhost popfile]$ uname -a
Linux localhost.localdomain 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

 

まずは、POPFileをダウンロードします。

[web@localhost popfile]$ wget http://getpopfile.org/downloads/popfile-1.1.3.zip
--2018-08-02 14:12:10-- http://getpopfile.org/downloads/popfile-1.1.3.zip
Resolving getpopfile.org... 85.214.59.241
Connecting to getpopfile.org|85.214.59.241|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 523431 (511K) [application/zip]
Saving to: “popfile-1.1.3.zip”

100%[============================================================================>] 523,431 208K/s in 2.5s

2018-08-02 14:12:13 (208 KB/s) - “popfile-1.1.3.zip” saved [523431/523431]

 

ダウンロードしたファイルを展開します。

[web@localhost popfile]$ unzip popfile-1.1.3.zip
Archive: popfile-1.1.3.zip
inflating: bayes.pl
extracting: black.gif
inflating: Classifier/Bayes.pm
inflating: Classifier/MailParse.pm
inflating: Classifier/popfile.sql
inflating: Classifier/WordMangle.
--- 省略 ----

[web@localhost popfile]$ ls
bayes.pl Classifier insert.pl license otto.png pix.gif popfile-1.1.3.zip popfile.pl Services stopwords v1.1.3.change
black.gif favicon.ico languages otto.gif pipe.pl POPFile popfile.pck Proxy skins UI v1.1.3.change.nihongo

 

Perlで書かれたpopfile.plを実行してみます。

[web@localhost popfile]$ perl ./popfile.pl
ERROR: POPFile needs Perl module Date::Format, please install it.
ERROR: POPFile needs Perl module Date::Parse, please install it.
ERROR: POPFile needs Perl module HTML::Template, please install it.

POPFile Engine loading

Loading...
Can't locate Date/Parse.pm in @INC (@INC contains: . /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at POPFile/History.pm line 35.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.
BEGIN failed--compilation aborted at POPFile/History.pm line 35.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.
Compilation failed in require at POPFile/Loader.pm line 484.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.
{core: config

エラーで終了してしまいました。
Can’t locate Date/Parse.pm in @INC (@INC contains:
と出ていますので、perl-DateTime-Format-DateParse を入れます。

[web@localhost popfile]$ sudo yum install perl-DateTime-Format-DateParse
[sudo] password for web:
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package perl-DateTime-Format-DateParse.noarch 0:0.04-1.1.el6 will be installed
--> Processing Dependency: perl(Time::Zone) >= 2.22 for package: perl-DateTime-Format-DateParse-0.04-1.1.el6.noarch
--- 省略 ----

Installed:
perl-DateTime-Format-DateParse.noarch 0:0.04-1.1.el6

Dependency Installed:
perl-Class-Singleton.noarch 0:1.4-6.el6 perl-DateTime.x86_64 1:0.5300-3.el6 perl-List-MoreUtils.x86_64 0:0.22-10.el6
perl-Params-Validate.x86_64 0:0.92-3.el6 perl-TimeDate.noarch 1:1.16-13.el6

Complete!

さあ、どうでしょうか?

[web@localhost popfile]$ perl ./popfile.pl
ERROR: POPFile needs Perl module HTML::Template, please install it.

POPFile Engine loading

Loading...
{core: config history logger mq}
{classifier: wordmangle bayes}
Can't locate HTML/Template.pm in @INC (@INC contains: . /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at UI/HTML.pm line 37.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.
BEGIN failed--compilation aborted at UI/HTML.pm line 37.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.
Compilation failed in require at POPFile/Loader.pm line 484.
Can't call method "parameter" without a package or object reference at POPFile/Module.pm line 453.

Can’t locate HTML/Template.pm in @INC (@INC contains:
と出ていますので、perl-HTML-Template を入れます。

[web@localhost popfile]$ sudo yum install perl-HTML-Template
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
No package perl-HTML-Template available.
Error: Nothing to do

現在のレポジトリ上に見つかりませんでした。
https://centos.pkgs.org/6/epel-i386/perl-HTML-Template-2.9-10.el6.noarch.rpm.html
で確認をすると、EPEL “Extra Packages for Enterprise Linux”上にあるようなので、レポジトリを追加します。

以上ページで紹介されている方法でもいいですが、

Install Howto
1. Download the latest epel-release rpm from
http://dl.fedoraproject.org/pub/epel/6/i386/

2.Install epel-release rpm:
# rpm -Uvh epel-release*rpm

3. Install perl-HTML-Template rpm package:
# yum install perl-HTML-Template

こちらだと一発でできます。
#sudo yum localinstall http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

[web@localhost popfile]$ sudo yum localinstall http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
Loaded plugins: fastestmirror, security
Setting up Local Package Process
epel-release-6-8.noarch.rpm | 14 kB 00:00
Examining /var/tmp/yum-root-Y1nFXZ/epel-release-6-8.noarch.rpm: epel-release-6-8.noarch
Marking /var/tmp/yum-root-Y1nFXZ/epel-release-6-8.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed

--- 省略 ----

Running Transaction
Installing : epel-release-6-8.noarch 1/1
Verifying : epel-release-6-8.noarch 1/1

Installed:
epel-release.noarch 0:6-8

Complete!

リポジトリの追加完了です。
再度、perl-HTML-Templateを入れてみます。

[web@localhost popfile]$ sudo yum install perl-HTML-Template
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink | 6.1 kB 00:00
* base: ftp.riken.jp
* epel: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
epel | 3.2 kB 00:00
epel/primary | 3.2 MB 00:00
epel 12516/12516
Resolving Dependencies
--> Running transaction check
---> Package perl-HTML-Template.noarch 0:2.9-10.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Running Transaction
Installing : perl-HTML-Template-2.9-10.el6.noarch 1/1
Verifying : perl-HTML-Template-2.9-10.el6.noarch 1/1

Installed:
perl-HTML-Template.noarch 0:2.9-10.el6

Complete!

パッケージが見つかり無事に完了しました。
さて、popfileは動くでしょうか。

[web@localhost popfile]$ perl ./popfile.pl

POPFile Engine loading

Loading...
{core: config history logger mq}
{classifier: wordmangle bayes}
{interface: xmlrpc html}
{proxy: pop3 smtp nntp}
{services: imap}

POPFile Engine v1.1.3 starting

Initializing...
{core: config history logger mq}
{classifier: bayes wordmangle}
{interface: html xmlrpc}
{proxy: nntp pop3 smtp}
{services: imap}

Starting...
{core: config history logger mq}
{classifier: bayes wordmangle}
{interface: html}

Couldn't start the pop3 proxy because POPFile could not bind to the
listen port 110. This could be because there is another service
using that port or because you do not have the right privileges on
your system (On Unix systems this can happen if you are not root
and the port you specified is less than 1024).

Failed to start while starting the pop3 module at POPFile/Loader.pm line 748.
{proxy:

POPFile Engine v1.1.3 stopping

Stopping...
{classifier: bayes wordmangle}
{core: config history logger mq}
{interface: html}
{proxy: pop3 smtp}
{services: imap}

POPFile Engine v1.1.3 terminated

>This could be because there is another service using that port

こちらの原因の確認。110番ポートがすでに使われているかチェック。

[web@localhost popfile]$ sudo lsof -i:110
[sudo] password for web:
[web@localhost popfile]$

110番ポートを使っているプログラムはありません。
それでは、もう一つの可能性の確認。

>because you do not have the right privileges on your system

正しい権限でないかもということですね。
sudoを使って、root権限で実行してみます。

[web@localhost popfile]$ sudo perl ./popfile.pl
[sudo] password for web:

POPFile Engine loading

Loading...
{core: config history logger mq}
{classifier: wordmangle bayes}
{interface: xmlrpc html}
{proxy: pop3 smtp nntp}
{services: imap}

POPFile Engine v1.1.3 starting

Initializing...
{core: config history logger mq}
{classifier: bayes wordmangle}
{interface: html xmlrpc}
{proxy: nntp pop3 smtp}
{services: imap}

Starting...
{core: config history logger mq}
{classifier: bayes wordmangle}
{interface: html}
{proxy: pop3}
{services:}

POPFile Engine v1.1.3 running

プロセスが待機状態になりました。

[web@localhost popfile]$ sudo lsof -i:110
[sudo] password for web:
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
perl    27823 root    5u  IPv4  41853      0t0  TCP localhost:pop3 (LISTEN)

110番ポートがLISTENとなっています。ここまでは問題なさそうです。
次回は、Web画面上からの仕分け設定について書きます。