RE: sa-learn and exchange integration

2013-08-19 Thread Chluz
Hi all, 
I just registered to be able to post this. I have a working solution for
learning with sa-learn messages placed into a special folders by exchange
2013 users. 
This works for me as I have a small number of users (this is a family
server) but might be adapted to more corporate infrastructure without having
to create login files for each user.

As you may know, public folders cannot be accessed through imap anymore
under exchange 2013. (I haven't been able to and the literature says I
shouldn't be able to, but if someone managed, please tell me.) However, all
mail from each root folder for each user can be downloaded to the
spamassassin mail gateway using offlinebackup. 

The idea is to create a root folder in the mailbox of each user in your
organisation called say 'Learn As Spam'. I did this manually, but you can
probably do a bulk add for large organisation using the info in this link 
http://careexchange.in/create-a-custom-root-folder-in-all-the-mailboxes-bulk-in-exchange-2010/

 
.

Next setup offlineimap to download the contents of that folder only for all
users and store it in '/SpamLearn/' in your mail gateway. Again, I do this
manually, but I suspect people can use the  script I give in post 15 of this
thread  http://www.howtoforge.com/forums/showthread.php?t=60708&page=2
   to create
a file containing the list of email addresses of valid users of your
exchange organisation, and then write a script to cycle through the list of
those emails, logging in to the email accounts using the mail admin
credentials (note that you need to have given access to all mailboxes with
the mail admin credentials using this link 
http://social.technet.microsoft.com/Forums/exchange/en-US/a88dfbd3-8461-4848-90a8-003044805de0/grant-full-access-to-all-mailboxes-in-particular-domain

 
. I haven't tested this automated way, but if admin has imap acces it should
work). 

Once you have the emails all stored in a folder of your mail gateway, I then
use this script to learn all mails and delete the learnt mails. Credits for
script go to Freddie Witherden. Mail.domain.com is my mail server running
exchange and gateway.domain.com is my mail gateway server running
spamassassin

#! /bin/sh

[ -x /usr/bin/sa-learn ] || exit 0

# Sync Imap Folder, activate this only if offline imap is not started on
boot
#offlineimap -o

# For every existing user folder in SpamLearn
for i in /SpamLearn/*;
do
if [ -d "$i/Learn As Spam/cur" ];
then
cd "$i/Learn As Spam/cur"
# Get the mails to train spamassassin
for f in *; do
if [ -e "$f" ]; then
   # Start by removing the headers generated by exchange
and co
sed -i '/^Received: from
mail.domain.com/,/^Received: by gateway.domain.com/{d}' "$f"
sed -i '/Received:/,$!d' "$f"
sed -i
'/^X-MS-Exchange-Organization-Network-Message-Id/,/^X-MS-Exchange-Organization-AuthAs/{d}'
"$f"
sed -i
'/^X-domain-MailScanner-Information/,/^X-domain-MailScanner-From/{d}' "$f"
# Debian-exim does not have read access to the mails
so we pipe them
cat "$f" | su - -s /bin/bash mail -c "sa-learn
--spam" | grep -v "Learned tokens from"
# Move files to the Spam dir
#mv "$f" ../../.Junk/cur/
# Or just delete it
rm -f "$f"
fi
done
fi;
if [ -d "$i/Learn As Spam/new" ];
then
cd "$i/Learn As Spam/new"
# Get the mails to train spamassassin
for f in *; do
if [ -e "$f" ]; then
   # Start by removing the headers generated by exchange
and co
sed -i '/^Received: from
Server.domain.com/,/^Received: by gateway.domain.com/{d}' "$f"
sed -i '/Received:/,$!d' "$f"
sed -i
'/^X-MS-Exchange-Organization-Network-Message-Id/,/^X-MS-Exchange-Organization-AuthAs/{d}'
"$f"
sed -i
'/^X-domainMailScanner-Information/,/^X-domain-MailScanner-From/{d}' "$f"

   # Debian-exim does not have read access to the mails
so we pipe them
cat "$f" | su - -s /bin/bash mail -c "sa-learn
--spam" | grep -v "Learned tokens from"
# Move files to the Spam dir
#mv "$f" ../../.Junk/cur/
# Or just delete it
rm -f "$f"
fi
done
fi;
done

# Print completed
# echo 'SpamAssassin Learn Completed.'
exit 0

Note that I use a l

RE: sa-learn and exchange integration

2013-02-13 Thread Steven Manross
What exactly are you looking for?

I have a Windows perl script that sa-learns from an Exchange Public
Folder - (It requires an account with access to Exchange, Outlook and a
COM component available on the Internet along with some modification to
Exchange security to allow scripting the Outlook client).

Let me know if you are interested in hearing more offline.

P.S. I am mostly a lurker to this forum...  until someone brings up the
word Exchange.  :)

Steven 
-Original Message-
From: Axb [mailto:axb.li...@gmail.com] 
Sent: Wednesday, February 13, 2013 1:17 AM
To: users@spamassassin.apache.org
Subject: Re: sa-learn and exchange integration

On 02/13/2013 09:11 AM, Per-Erik Persson wrote:
> Has anyone seen a tool for the integration between sa-learn and 
> microsoft exchange?
>
> Ideally I would like  a tool like this:
> ./sa-learn-wrapper  --server=XXX --credentials-XXX --spam|ham 
> --matchingpattern=XXX
>
> I started writing one myself a while ago but stumbled upon the fact 
> that the the imapserver in exchange cannot change to a folder that is 
> not "personal", to do that you need a real MAPI connection.
>
> Any solutions?

imapsync to a *nix IMAP instance and sa-learn from there Probably the
simplest/safest/most efficient



Re: sa-learn and exchange integration

2013-02-13 Thread Benny Pedersen

Axb skrev den 2013-02-13 09:16:


imapsync to a *nix IMAP instance and sa-learn from there
Probably the simplest/safest/most efficient


+1, hope the headers exchange adds is ignored in bayes learn with 
sa-learn, is sa-learn inhirit bayes_ignore, else it will make bayes 
poison imho






Re: sa-learn and exchange integration

2013-02-13 Thread Benny Pedersen

Per-Erik Persson skrev den 2013-02-13 09:11:

Has anyone seen a tool for the integration between sa-learn and
microsoft exchange?


is it still supported from micro$oft ?


Ideally I would like  a tool like this:
./sa-learn-wrapper  --server=XXX --credentials-XXX --spam|ham
--matchingpattern=XXX


that would maybe be like dovecot-antispam ?, where users just move msgs 
to a junk folder and then the imap protocol call dspam by default, and 
all dspam search for is the dspam signature either in headers, or in 
body, then dspam knows what to do for what content, and the last to 
resort is just to relearn it as spam or ham


have exchange such api ?

I started writing one myself a while ago but stumbled upon the fact 
that

the the imapserver in exchange cannot change to a folder that is not
"personal", to do that you need a real MAPI connection.


not shared folder possible ?, all of my networking members drops 
exchange and go to google apps mx setups, dont know why :=)



Any solutions?


dovecot 2.x with dovecot-antispam



Re: sa-learn and exchange integration

2013-02-13 Thread Robert Schetterer
Am 13.02.2013 09:55, schrieb Per-Erik Persson:
> However doing some new searches revealed the openchange project which
> claims to have a working mapiclient.

yeah perhaps go this way, however exchange is a product from m$
so it designed and meant to use with m$ or partners products usally not
with open software, so if you choose exchange you choose the m$ way,
which is ok anyway but dont expect matching open source stuff with it
any time/task


Best Regards
MfG Robert Schetterer

-- 
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer
Aufsichtsratsvorsitzender: Joerg Heidrich


Re: sa-learn and exchange integration

2013-02-13 Thread Per-Erik Persson
On 02/13/2013 09:19 AM, Robert Schetterer wrote:
>
>> you mean pure exchange ?
>> not filtering linux gateway before exchange ?
To clarify, linux gataways but mail storage is mostly done in an
exchange server.
>>
>> Best Regards
>> MfG Robert Schetterer
>>
> look
>
> http://wiki.mailscanner.info/doku.php?id=documentation:anti_spam:spamassassin:sa-learn:msexchange
>
> should be able to get  adapted to your needs with pure exchange
>
>
Thanks, it looks mostly like my script I can only agree that it probably
works on exchange 2003 like the wiki says :-)
The main problem here is that the folders that store the spam is not
accessible via imap, but a solution that establishes a gateway or in the
worst case syncronizes the emails to a normal imapserver is the only
solution if an exchange-mapi connection to the linuxworld is not possible.

However doing some new searches revealed the openchange project which
claims to have a working mapiclient.



Re: sa-learn and exchange integration

2013-02-13 Thread Robert Schetterer
Am 13.02.2013 09:16, schrieb Robert Schetterer:
> Am 13.02.2013 09:11, schrieb Per-Erik Persson:
>> Has anyone seen a tool for the integration between sa-learn and
>> microsoft exchange?
>>
>> Ideally I would like  a tool like this:
>> ./sa-learn-wrapper  --server=XXX --credentials-XXX --spam|ham
>> --matchingpattern=XXX
>>
>> I started writing one myself a while ago but stumbled upon the fact that
>> the the imapserver in exchange cannot change to a folder that is not
>> "personal", to do that you need a real MAPI connection.
>>
>> Any solutions?
>>
>>
> 
> you mean pure exchange ?
> not filtering linux gateway before exchange ?
> 
> 
> Best Regards
> MfG Robert Schetterer
> 

look

http://wiki.mailscanner.info/doku.php?id=documentation:anti_spam:spamassassin:sa-learn:msexchange

should be able to get  adapted to your needs with pure exchange


Best Regards
MfG Robert Schetterer

-- 
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer
Aufsichtsratsvorsitzender: Joerg Heidrich


Re: sa-learn and exchange integration

2013-02-13 Thread Axb

On 02/13/2013 09:11 AM, Per-Erik Persson wrote:

Has anyone seen a tool for the integration between sa-learn and
microsoft exchange?

Ideally I would like  a tool like this:
./sa-learn-wrapper  --server=XXX --credentials-XXX --spam|ham
--matchingpattern=XXX

I started writing one myself a while ago but stumbled upon the fact that
the the imapserver in exchange cannot change to a folder that is not
"personal", to do that you need a real MAPI connection.

Any solutions?


imapsync to a *nix IMAP instance and sa-learn from there
Probably the simplest/safest/most efficient



Re: sa-learn and exchange integration

2013-02-13 Thread Robert Schetterer
Am 13.02.2013 09:11, schrieb Per-Erik Persson:
> Has anyone seen a tool for the integration between sa-learn and
> microsoft exchange?
> 
> Ideally I would like  a tool like this:
> ./sa-learn-wrapper  --server=XXX --credentials-XXX --spam|ham
> --matchingpattern=XXX
> 
> I started writing one myself a while ago but stumbled upon the fact that
> the the imapserver in exchange cannot change to a folder that is not
> "personal", to do that you need a real MAPI connection.
> 
> Any solutions?
> 
> 

you mean pure exchange ?
not filtering linux gateway before exchange ?


Best Regards
MfG Robert Schetterer

-- 
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer
Aufsichtsratsvorsitzender: Joerg Heidrich