Use POPFile at Linux
CREATED:
UPDATED:
POPFile automatically sorts emails.
Install POPFile
Download and extract cross-platform version to ~/bin/popfile/
.
Install third party packages
Run:
cpan DBD::SQLite DBI Date::Format Date::Parse HTML::Tagset HTML::Template IO::Socket::SSL Net::IDN::Encode Mozilla::CA Encode:IMAPUTF7
When being asked by cpan, say you prefer installing local lib.
My cpan configuration ~/.cpan/CPAN/MyConfig.pm
,
$CPAN::Config = {
'applypatch' => q[],
'auto_commit' => q[0],
'build_cache' => q[100],
'build_dir' => q[/home/cb/.cpan/build],
'build_dir_reuse' => q[0],
'build_requires_install_policy' => q[yes],
'bzip2' => q[/bin/bzip2],
'cache_metadata' => q[1],
'check_sigs' => q[0],
'colorize_output' => q[0],
'commandnumber_in_prompt' => q[1],
'connect_to_internet_ok' => q[1],
'cpan_home' => q[/home/cb/.cpan],
'ftp_passive' => q[1],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gpg' => q[/usr/bin/gpg],
'gzip' => q[/bin/gzip],
'halt_on_failure' => q[0],
'histfile' => q[/home/cb/.cpan/histfile],
'histsize' => q[100],
'http_proxy' => q[],
'inactivity_timeout' => q[0],
'index_expire' => q[90],
'inhibit_startup_message' => q[0],
'keep_source_where' => q[/home/cb/.cpan/sources],
'load_module_verbosity' => q[none],
'make' => q[/usr/bin/make],
'make_arg' => q[],
'make_install_make_command' => q[/usr/bin/make],
'mbuild_arg' => q[--install-dirs site],
'mbuild_install_arg' => q[./Build],
'mbuild_install_build_command' => q[./Build],
'mbuildpl_arg' => q[--installdirs site],
'no_proxy' => q[],
'pager' => q[/usr/bin/less],
'patch' => q[/usr/bin/patch],
'perl5lib_verbosity' => q[none],
'prefer_external_tar' => q[1],
'prefer_installer' => q[MB],
'prefs_dir' => q[/home/cb/.cpan/prefs],
'prerequisites_policy' => q[follow],
'recommends_policy' => q[1],
'scan_cache' => q[atstart],
'shell' => q[/bin/bash],
'show_unparsable_versions' => q[0],
'show_upload_date' => q[0],
'show_zero_versions' => q[0],
'suggests_policy' => q[0],
'tar' => q[/bin/tar],
'tar_verbosity' => q[none],
'term_is_latin' => q[1],
'term_ornaments' => q[1],
'test_report' => q[0],
'trust_test_report_history' => q[0],
'unzip' => q[/usr/bin/unzip],
'urllist' => [q[http://mirror.optusnet.com.au/CPAN/]],
'use_prompt_default' => q[0],
'use_sqlite' => q[0],
'version_timeout' => q[15],
'wget' => q[/usr/bin/wget],
'yaml_load_code' => q[0],
'yaml_module' => q[YAML],
};
__END__
cpan
will append setup into ~/.bashrc
,
PATH="$HOME/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"$HOME/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; export PERL_MM_OPT;
Double check installed packages:
perl -MDBI -e 'print $MIME::DBI::VERSION'
If there is any error:
perl -V
rm -rf ~/perl5/*
cpan DBD::SQLite DBI Date::Format Date::Parse HTML::Tagset HTML::Template IO::Socket::SSL Net::IDN::Encode MOZILLA::CA
Setup
I only use IMAP. The purpose of tweak POP3 port is only to make the program executable without root permission.
See http://getpopfile.org/docs/howtos:mayneedroot for details.
Run the below command to fix the root issue.
sed -i 's/pop3_port \+110/pop3_port 1110/g' ~/bin/popfile/popfile.cfg
Davmail is a gateway to convert Outlook/Exchange service to IMAP/POP3). It's required if and only if you use Microsoft's Exchange/Outlook.
If you don't use Davmail and fetch mails directly, you'd better set imap_expunge 1
to fix Microsoft Office 365 issue.
Please disable ssl if running local Davmail Server only. Or else, ssl should be enabled.
My popfile setup,
bayes_bad_sqlite_version 4.0.0
bayes_corpus corpus
bayes_database popfile.db
bayes_dbauth
bayes_dbconnect dbi:SQLite:dbname=$dbname
bayes_dbuser
bayes_hostname 192-168-1-3.tpgi.com.au
bayes_localhostname
bayes_nihongo_parser kakasi
bayes_sqlite_journal_mode delete
bayes_sqlite_tweaks 4294967295
bayes_subject_mod_left [
bayes_subject_mod_pos 1
bayes_subject_mod_right ]
bayes_unclassified_weight 100
bayes_xpl_angle 0
config_pidcheck_interval 5
config_piddir ./
GLOBAL_debug 1
GLOBAL_last_update_check 1407715200
GLOBAL_message_cutoff 100000
GLOBAL_msgdir messages/
GLOBAL_ssl_verify_peer_certs 0
GLOBAL_timeout 60
GLOBAL_update_check 1
history_archive 0
history_archive_classes 0
history_archive_dir archive
history_history_days 2
html_cache_templates 0
html_column_characters 0
html_columns +inserted,+from,+to,-cc,+subject,-date,-size,+bucket
html_date_format
html_language English
html_last_reset Sat Dec 1 11:06:48 2012
html_local 0
html_page_size 20
html_password b6b3637136ad630eba43aa5ee7106780
html_port 8888
html_search_filter_highlight 0
html_send_stats 1
html_session_dividers 1
html_show_bucket_help 1
html_show_training_help 0
html_skin simplyblue
html_strict_templates 0
html_test_language 0
html_wordtable_format
imap_bucket_folder_mappings job-->job-->geek-->geek-->business-->business-->ad-->ad-->unclassified-->INBOX-->work-->work-->
imap_enabled 1
imap_expunge 1
imap_hostname localhost
imap_login binc1
imap_password password1
imap_port 1143
imap_training_mode 0
imap_uidnexts work-->749-->job-->5914-->INBOX-->20736-->geek-->5009-->ad-->1296-->business-->15-->
imap_uidvalidities job-->98-->work-->107-->ad-->100-->business-->106-->geek-->99-->INBOX-->2-->
imap_update_interval 1000
imap_use_ssl 0
imap_watched_folders INBOX-->INBOX-->
logger_format default
logger_level 0
logger_logdir ./
nntp_enabled 0
nntp_force_fork 1
nntp_headtoo 0
nntp_local 1
nntp_port 119
nntp_separator :
nntp_socks_port 1080
nntp_socks_server
nntp_welcome_string NNTP POPFile (v1.1.3) server ready
pop3_enabled 0
pop3_force_fork 1
pop3_local 1
pop3_port 1110
pop3_secure_port 110
pop3_secure_server
pop3_separator :
pop3_socks_port 1080
pop3_socks_server
pop3_toptoo 0
pop3_welcome_string POP3 POPFile (v1.1.3) server ready
smtp_chain_port 25
smtp_chain_server
smtp_enabled 0
smtp_force_fork 1
smtp_local 1
smtp_port 25
smtp_socks_port 1080
smtp_socks_server
smtp_welcome_string SMTP POPFile (v1.1.3) welcome
xmlrpc_enabled 0
xmlrpc_local 1
xmlrpc_port 8081
The only remaining issue is user name. If it contains "\", you should replace it with "\\" when inputting in Popfile!
Run the program
See http://getpopfile.org/docs/howtos:runlocation for details.
cd ~/bin/popfile;perl popfile.pl
Start the POPFile automatically when bash login
Insert below code in ~/.bashrc:
OS_NAME=`uname -s`
if [ $OS_NAME == Linux ]; then
# start popfile
if [ -f $HOME/bin/popfile/popfile.pl ]; then
# @see http://getpopfile.org/docs/howtos:runlocation
pop_pid=`ps -ef | grep perl | grep popfile.pl | gawk '{print $2}'`
if [ "${pop_pid}" = "" ] ; then
cd $HOME/bin/popfile
perl popfile.pl >> /dev/null 2>&1 &
fi
cd $HOME
fi
fi
Start the POPFile systemd service as a user (OPTIONAL)
My user name is cb. Put popfile.service in usr/lib/systemd/system. Then run `systemctl enable popfile` to install service. Run `systemctl start popfile` to start the service. My Linux distribution is ArchLinux.
here is content of popfile.service.
[Unit]
Description=POPFile (Automatic Email Classification) Service
[Service]
WorkingDirectory=/home/cb/bin/popfile
ExecStart=/usr/bin/perl popfile.pl
User=cb
[Install]
WantedBy=multi-user.target
Backup
Please backup popfile.cfg and popfile.db.
See http://getpopfile.org/docs/howtos:backup for details.
Summary
- Portable
- No root privilege needed
- No X windows needed. I can manage mails in remote shell