Forums: users (Thread #6243)

Subject: [SPAM] (2004-10-25 21:55 by suzu-kat #11643)

こんにちは。
Windows-XPでWeMail32というMUAを使っております。
bsfilter をローカル POP proxy として使い始めてみましたが、WeMail32 の振り分け機能の方が X-Spam-Filter を参照出来ないことに後から気づきました (--;

そこで、X-Spam-Flag: Yes と同じ条件で Subject に [SPAM] を追加する簡単なパッチを作ってみました。

Ruby のソースを見るのは初めてだったので妙なことをしているかも知れませんが、同じようにシンプルな振り分け機能しか持っていないメールソフトも多かろうと思いましたので、投稿します。

簡単な使い方:
オプションに --mark-subject を指定して起動すると、Subject ヘッダに [SPAM] を追加します。

以下パッチ本文です。
----
*** bsfilter.orig Mon Oct 25 13:08:47 2004
--- bsfilter Mon Oct 25 16:09:08 2004
***************
*** 1,5 ****
--- 1,6 ----
#! /usr/bin/env ruby
## -*-Ruby-*- $Id: bsfilter,v 1.65 2004/10/23 18:47:18 nabeken Exp $
+ # Added --mark-subject option by suzu-kat 2004/10/25

## Copyright (C) 2003, 2004 NABEYA Kenichi
##
***************
*** 17,22 ****
--- 18,24 ----
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

+
require 'getoptlong'
require 'nkf'

***************
*** 121,126 ****
--- 123,140 ----
end
end

+ def mark_subject!(buf, marker) # by suzu-kat 2004/10/25
+ buf[0] =~ /([\r\n]*)\z/
+ eol = $1
+
+ (0 ... buf.length).each do |i|
+ if (buf[i] =~ /\ASubject:/)
+ buf[i] = buf[i].gsub( /Subject: /, "Subject: #{marker} ")
+ break
+ end
+ end
+ end
+
def x_spam_flag
return sprintf("X-%s-Flag:", Options["header-prefix"])
end
***************
*** 151,156 ****
--- 165,177 ----
updated = true
insert_header!(buf, x_spam_probability, sprintf("%f", probability))
end
+ if (Options["mark-subject"]) # by suzu-kat 2004/10/25
+ if (spam_flag)
+ print "spam_flag\n"
+ updated = true
+ mark_subject!(buf, "[SPAM]")
+ end
+ end
return updated
end
end # end of module
***************
*** 1837,1842 ****
--- 1858,1866 ----
--insert-probability
insert "X-Spam-Probability: number" into a mail

+ --mark-subject
+ mark "[SPAM]" at the beginning of Subject header
+
--header-prefix string
insert "X-spcecified_string-..." headers, instead of "Spam"

***************
*** 2646,2651 ****
--- 2670,2676 ----
["--insert-flag", GetoptLong::NO_ARGUMENT],
["--insert-probability", GetoptLong::NO_ARGUMENT],
["--header-prefix", GetoptLong::REQUIRED_ARGUMENT],
+ ["--mark-subject", GetoptLong::NO_ARGUMENT],
["--list-clean", GetoptLong::NO_ARGUMENT],
["--list-spam", GetoptLong::NO_ARGUMENT],
["--show-db-status", GetoptLong::NO_ARGUMENT],

Reply to #11643×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Subject: [SPAM] (2004-10-26 00:29 by nabeken #11647)

outlook系で任意のヘッダでの振り分けが出来ないと聞いた記憶があり、しかし、1メイル1ファイルでないようなので、おそらく再学習が不可能と思い、Subjectにマークを入れる機能を付けてませんでした。
WeMail32では再学習に問題はないのでしょうか?
Reply to #11643

Reply to #11647×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Subject: [SPAM] (2004-11-10 19:37 by suzu-kat #11845)

なるほど、そういう意図なのですね。

WeMail32ではエクスポートしてもメールフォルダの中も1メール=1ファイルなので、うまく出来ています。

ただ、学習前に手作業でメールを修正しています:
(1) (念のため)X-Spam-FlagとX-Spam-Probabilityを削除。
(2) 誤って[SPAM]と付けられた場合は[SPAM]を削除。
私のところでは(2)のパターンは少ないので、妥協してそのまま使っています。

ついでに、上記パッチではSubject: 行を含まない SPAM に無力なのも課題です (Subject を追加しないので)。
Reply to #11643

Reply to #11845×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Subject: [SPAM] (2004-11-11 01:43 by nabeken #11857)

r165_marksubjectブランチで
--mark-subject
--subject-prefix
オプションを追加してみました。

WeMail32がそのような仕様であれば、安定した後に、main trunkに入れます。

再学習前の修正ですが、(1)は必要ありません。見ているヘッダは限られますので。
(2)は、おっしゃる通り、妥協コースですね。

Subjectがない場合には対応しているつもりです。
Reply to #11845

Reply to #11857×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Subject: [SPAM] (2004-12-16 20:19 by suzu-kat #12220)

こんにちは。
ブランチの作成、ありがとうございました。

一ヶ月ほど r165_marksubject ブランチを使ってみましたが、快適に使えておりますのでご報告します。
(環境は WinXP + Cygwin の ruby です)

Subjectがない SPAM もちゃんと "Subject: [SPAM]" と対応してくれました(^^)
Reply to #11857

Reply to #12220×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Subject: [SPAM] (2004-12-19 01:25 by nabeken #12249)

以下のようなオプションを追加し、1.0.6をリリースしました。
--mark-spam-subject
--spam-subject-prefix string
Reply to #12220

Reply to #12249×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login