Lens - $B%a!<%k?6$jJ,$1%W%m%0%i%`(B
Up$Date: 2004/02/12 05:47:59 $ $Revision: 1.20 $

Lens$B$O!"(B $BAw!"(B $B%3%^%s%I%a!<%k=hM}(B $B$J$I$r(B $B<+F/ 2003$BG/(B5$B7n9f5-;v(B$B$K4XO">pJs$,$"$j$^$9!#(B 2004$BG/(B2$B7nH/Gd$N(BUnixMagazine(3$B7n9f(B)$B$K$b4XO"5-;v$r=q$-$^$7$?!#(B
$B%a!<%k$N?6$jJ,$1$K$O(Bprocmail$B$,9-$/MxMQ$5$l$F$$$k$h$&$G$9$,!"(B procmail$B$O(B $B%P%C%I%N%&%O%&(B$B$,(B $BB??tI,MW$G$"$k$K$b$+$+$o$i$:=$N(B $B=hM}$r=

$B%K%e!<%9(B

  • $B8x3+3+;O(B (2004/2/10)

$B%@%&%s%m!<%I(B

$B%$%s%9%H!<%k(B

  • Makefile$B$N(BBINDIR$B$rJT=8(B (lens$B$N%$%s%9%H!<%k%G%#%l%/%H%j;XDj(B)
  • sudo make ($B%i%$%V%i%j$J$I$N%3%T!<(B)
  • ~/.lensrc, ~/.commandmailrc$B$rJT=8(B
  • lens$B$K$h$k?6$jJ,$1$=$NB>$,$&$^$/$$$/$h$&$G$"$l$P(B $B0J2<$N$h$&$J%F%-%9%H$r(B~/.forward$B$K@_Dj$9$k(B
    |/usr/local/bin/lens
    

$B;H$$$+$?(B

.lensrc$B$N@_Dj(B

~/.lensrc$B$G0J2<$N@_Dj$r5-=R$7$^$9!#(B
:smtp_host SMTP$B%[%9%HL>(B($B7HBS$X$NE>Aw$GMxMQ(B)
:local_address $B<+J,$N%a!<%k%"%I%l%9(B
:mobile_address $B7HBS%a!<%k%"%I%l%9(B
:maildir Maildir$B%G%#%l%/%H%j(B
:non_important_mls $B=EMW$G$J$$%a!<%j%s%0%j%9%HL>$N%j%9%H(B ($B7HBS$KE>Aw$7$J$$(B)
:subject_patterns Subject:$B$+$i$N%a!<%k?6$jJ,$1%Q%?%s(B
:from_patterns From:$B$+$i$N%a!<%k?6$jJ,$1%Q%?%s(B
:spam_patterns SPAM$B%a!<%k$N%Q%?%s(B

.lensrc$B$NNc(B

# Configuration for Lens

LensConfig = {
  :smtp_host => 'mail.example.com',
  :local_address => '[email protected]',
  :mobile_address => '[email protected]',
  :maildir => "#{ENV['HOME']}/Maildir",

  :non_important_mls => {
    'test-ml'		=> 'test-ml',
  },
  :subject_patterns => {
    'xyz-ml'		=> 'xyz',
  },
  :from_patterns => { # To: Cc: $B$K$bE,MQ$5$l$k(B
    'yamada'		=> ['person/yamada', '01yamad'],
  },
  :spam_patterns => {
    'Content-type'	=> [
      /gb2312/i,
    ],
    'From'		=> [
      /SmallCap/,
      ],
    'Subject'		=> [
      /ink.*jet.*toner/i,
      /health.*insurance/i,
    ],
  }
}

.commandmailrc$B$N@_Dj(B

$B%3%^%s%I%a!<%k$rMxMQ$9$k>l9g$O(B~/.commandmailrc$B$rE,Ev$K@_Dj$7$^$9!#(B

SPAM$BH=Dj%W%m%0%i%`$NMxMQ(B

lens$B$G$O(BSubject$B$d(BFrom$B$N(B $B%Q%?%s%^%C%A%s%0$K$h$k(BSPAM$BH=Dj$7$+%5%]!<%H$7$F$$$^$;$s$,!"(B Message$B%/%i%9$N(Bspam_contents?$B%a%=%C%I$r<+J,$GDj5A$9$l$P(B $BG$0U$N(BSPAM$BH=Dj%W%m%0%i%`$rMxMQ$9$k$3$H$,$G$-$^$9!#(B

$B$9$Y$F$N?M$KM-8z$J(BSPAM$BH=Dj%W%m%0%i%`$,$"$l$P(B classify.rb$BFb$G$3$N%a%=%C%I$rDj5A$9$l$P$$$$$N$G$9$,!"(B $B$=$&$G$J$$>l9g$O<+A0$N(BSPAM$BH=Dj%W%m%0%i%`$rMxMQ$7$?J}$,NI$$$G$7$g$&!#(B $B;d$O0J2<$N$h$&$K(B~/.lensrc$BFb$G(Bspam_contents?$B$rDj5A$9$k$3$H$K$h$j(B bsfilter$B$H$$$&(B SPAM$BH=Dj%W%m%0%i%`$rMxMQ$7$F$$$^$9!#(B

class Message
  def spam_contents?
    system "/home/masui/bin/bsfilter -m rf --homedir /home/masui/SpamFilter/.bsfilter < #{path}"
  end
end
SPAM$BB`<#$NJ}K!$K$D$$$F$O!";d$,=q$$$?(B ASCII$B5-;v(B $B$J$I$,;29M$K$J$k$+$b$7$l$^$;$s!#(B

$BCm0U(B

  • .forward$B$K5-=R$7$?(Blens$B$,8mF0:n$9$k$H%a!<%k$,<:$o$l$F$7$^$&$3$H$,$"$k$N$G!"(B $B1?MQ;~$O= % cat testmail | lens $B$J$I$r Maildir$B$N(Ba/b$B$H$$$&%U%)%k%@$O!"(B Maildir/.a.b/$B$H$$$&(B $B%G%#%l%/%H%j$r;H$&$H2>Dj$7$F$$$^$9!#(B $B$3$l$H0[$J$k%G%#%l%/%H%jL>$r;H$&(BMaildir$B$N>l9g$O(B $B%W%m%0%i%`$N=$@5$,I,MW$G$9!#(B

TODO

$B99?7MzNr(B

  • lens-0.2.tar.gz (2004/2/12)
    • require 'lens/commandmail' $B$r:o=|(B
    • Maildir$B$H(B/tmp/$B$N%U%!%$%k%7%9%F%`$,0[$J$C$F$$$k$H$-H/@8$9$kLdBj=$@5(B
  • lens-0.1.tar.gz (2004/2/10)

Up$Date: 2004/02/12 05:47:59 $ Toshiyuki Masui @ AIST