Last Update: "2010/01/04 01:18:33 makoto"

sieve

sieve は cyrus-imapd で利用出来るメールの振分系です。
cd mail/cyrus-imapd make package
で設置されます。sieve での振分を設定する言語は RFC 3028 で定義されています。例えば次のようなところに情報があります。
S.C. MAGI-SYSTEM 日記 から
http://www.magisystem.net/diary/?20040321
RFC 3028 (英語)
http://rfc.sunsite.dk/rfc/rfc3028.html
Cyrus IMAP serverでsieveを使う
http://www.j.dendai.ac.jp/~fujimoto/FreeBSD/cyrus-sieve.html
設定
/usr/pkg/etc/cyrus.conf /usr/pkg/etc/imapd.conf
serv timsieved[18469]: can't use home directories
sieveusehomedir: true
 |
 v
## sieveusehomedir: true
.sieve
allof とか anyof を見ると、いささか「何だらう」と思ふが、これは単に AND や OR の意味をさふ書くだけらしい。
記述 意味
anyof OR
allof AND
.sieve を生成するための元の譜には次のような形の文を書きます。
 if anyof (not exists ["From", "Date"],
                   header :contains "from" "fool@example.edu") {
                discard;
             }
つまり、次のような形式です。
if ( 論理 ) { 操作 }
あるいは:
if ( 論理 ) { 操作 }
else (    ) {   }
上記例意味
if control commands
論理 test commands
操作 action commands
操作
action commands に書けるのは次のやうなものです。
操作 意味
reject 受取らない
fileinto 譜に保存
redirect 転送
keep 通常の処理 (メール box に保存)
discard 捨てる
検査
test commands には次のものが書けます。
検査 意味
address
allof AND
anyof OR
envelope メール転送情報(発信元等)
exists
false
header メールの見出に header :is "Sender"....
not
size
true
有効にするには
ttyp0:mayumi@st4200  9:12:18/061218(~)> sieveshell localhost
connecting to localhost
Please enter your password: 
> put .sieve.script
upload failed: put script: script errors:
line 10: syntax error, unexpected '}', expecting ';'

> put .sieve.script
> activate sieve
activate failed: Setting script active: Script does not exist
> list    
.sieve 
> activate .sieve
> list
.sieve  <- active script
> quit
ttyp0:mayumi@st4200  9:14:47/061218(~)> 
問題
#2 [pkgsrc] sieveshell localhost

# sieveshell localhost 
connecting to localhost
Bad protocol from MANAGESIEVE server: EOL2

In /usr/pkg/etc/imapd.conf,

change the line
sieveusehomedir: true
to
# sieveusehomedir: true

(http://www.cwinters.com/News/display/?news_id=893)
saslauthd
ttyp0:makoto@st4200 18:16:49/061216(~....pkgsrc/attach)> sieveshell localhost
connecting to localhost
unable to connect to server at /usr/pkg/bin/sieveshell line 169.
ttyp0:makoto@st4200 18:16:55/061216(~....pkgsrc/attach)> 
BAD case:
ttyp1:root@bwg3 10:55:15/070810(...cf/cf)# telnet localhost 2000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
"IMPLEMENTATION" "Cyrus timsieved v2.2.13"
"SIEVE" "fileinto reject envelope vacation imapflags notify subaddress 
	relational comparator-i;ascii-numeric regex"
OK
GOOD case:
ttyp0:makoto@st4200 10:55:04/070810(~)>  telnet localhost 2000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
"IMPLEMENTATION" "Cyrus timsieved v2.2.13"
"SASL" "PLAIN LOGIN CRAM-MD5"
"SIEVE" "fileinto reject envelope vacation imapflags notify subaddress 
	relational comparator-i;ascii-numeric regex"
OK
. logout
NO "Expected a command. Got something else."
NO "Expected a command. Got something else."
OK "Logout Complete"
Connection closed by foreign host.
Ref: http://linux.derkeiler.com/Mailing-Lists/SuSE/2005-09/1017.html

missing package:

cy2-login-2.1.22    Cyrus SASL LOGIN authentication plugin
cy2-plain-2.1.22    Cyrus SASL PLAIN authentication plugin
Following one was installed at above testing, but it is said confusing. Without this package, it is OK now.
cy2-crammd5-2.1.22  Cyrus SASL CRAM-MD5 authentication plugin
passwd is asked
ttyp0:makoto@bwg3 11:19:45/070810(~)> sieveshell localhost
connecting to localhost
Please enter your password: 
Please enter your password: 
unable to connect to server at /usr/pkg/bin/sieveshell line 169, <STDIN> line 2.
Aug 10 11:21:54 bwg3 saslauthd[18159]: do_auth         : auth failure: [user=mylogin] [service=sieve] [realm=] [mech=getpwent] [reason=Unknown]
Aug 10 11:21:54 bwg3 perl: No worthy mechs found
Aug 10 11:31:08 bwg3 sieve[19884]: IOERROR: creating directory /usr/sieve: Permission denied
Aug 10 11:31:08 bwg3 sieve[19884]: mkdir /usr/sieve: Permission denied
Aug 10 11:31:08 bwg3 sieve[19884]: error in actions_setuser()
add the line in imapd.conf
sievedir:/var/sieve
   151  12:40   vi /usr/pkg/etc/imapd.conf
   152  12:40   mkdir /var/sieve
   153  12:41   chown cyrus /var/sieve
Diary 2006/12/18
http://www.ki.nu/~makoto/diary/2006/12/18/
Cyrys SASL の使い方
http://d.hatena.ne.jp/obache/20080812/1218590863
saslauthd経由では、cram-md5認証ができない
http://www.ki.nu/~makoto/diary/board.cgi?act=read&msgid=177
Cyrus IMAP4 Serverよるメール環境の構築
http://hk-tech.homeip.net/pcserver/imap4.html