Tom Allison wrote:
> Paul J Stevens wrote:
>>
>> If you only want to read the Public/Spam box, why do you want to read
>> the box through SQL? Use fetchmail I'd say.
>>
>>
>
> I don't have pop configured and I am not sure about the next question:
> who do you authenticate as in order to access PUBLIC folders? I'll
> assume this depends on who has rights (ACL) to the folder.
Who's talking about POP. Fetchmail talks imap fluently.
Setup a user 'spamadmin' who has full access to the Public/Spam folder.
Subscribe all users to Public/Spam.
Setup a fetchmailrc that feeds the contents to sa-learn daily.
--- acl ---
insert into dbmail_acl values
(<spamadmin:user_idnr>,<Spam:mailbox_idnr>,1,1,1,1,1,1,1,1,1);
insert into dbmail_acl values
(<spamadmin:user_idnr>,<NoSpam:mailbox_idnr>,1,1,1,1,1,1,1,1,1);
--- /etc/fetchmailrc ---
poll localhost with protocol imap
user spamadmin
mda "/usr/bin/sa-learn --spam --single"
password sekret;
folder "\#Public/Spam"
keep
poll localhost with protocol imap
user spamadmin
mda "/usr/bin/sa-learn --ham --single"
password sekret;
folder "\#Public/NoSpam"
keep
--- autosubscriber ---
#!/bin/sh
# auto-subscribe all users to mailbox '#Public/Spam'
query() {
echo "$@" | mysql -N --batch dbmail
}
get_all_userids() {
query "select user_idnr from dbmail_users where userid not in
(\"[EMAIL PROTECTED]@!__\",\"__public__\",\"anyone\",\"spamadmin\")"
}
get_user_idnr() {
[ -n "$1" ] || return 1
query "select user_idnr from dbmail_users where userid =\"$1\""
}
get_mailboxid() {
[ -n "$1" ] || return 1
[ -n "$2" ] || return 1
mailbox="$1"
owner="$2"
query "select mailbox_idnr from dbmail_mailboxes where
name=\"$mailbox\" and owner_idnr=\"$owner\""
}
subscribe() {
user_idnr="$1"
mailbox_idnr="$2"
[ -n "$mailbox_idnr" ] || return 1
query "insert into dbmail_subscription values
(\"$user_idnr\",\"$mailbox_idnr\")" &>/dev/null
}
main() {
public_idnr=`get_user_idnr "__public__"`
spambox_idnr=`get_mailboxid "Spam" $public_idnr`
nospambox_idnr=`get_mailboxid "NoSpam" $public_idnr`
for user_idnr in `get_all_userids`; do
subscribe $user_idnr $spambox_idnr
subscribe $user_idnr $nospambox_idnr
done
}
main
------------------------------
--
________________________________________________________________
Paul Stevens paul at nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands________________________________http://www.nfg.nl