Re: processing of mail considered spam
Hi Noah, Am 2009-07-12 11:58:23, schrieb Admin: > okay how do I script sa-learn to learn the contents of a particular > file. I use courier (Maildir) with procmail and if I have spams, then I move it to the folder "INBOX.Learn_IS_Spam" and if I have ham found in the spamfolders, I move it to "INBOX.Learn_NO_Spam". [ '/home/michelle.konzack/bin/check_sa_learn' ]- #!/bin/bash VAL_USERS=$(cut -d ':' -f1,3,6 /etc/passwd |tr ':' ' ') HN=$(hostname -s) LOG=/var/log/check_sa_learn.$(date +%Y-%m-%d).log touch ${LOG} chown root:adm ${LOG} chmod 660 ${LOG} (echo "${VAL_USERS}" ; echo) | while read VAL_USER VAL_UID VAL_HOME do if [ -n "${VAL_USER}${VAL_UID}${VAL_HOME}" ] ; then if [ ${VAL_UID} -ge 1000 ] && [ ${VAL_UID} -lt 65000 ] ; then NUM_SPAM=$(ls ${VAL_HOME}/Maildir/.Learn_IS_Spam/{cur,new}/* 2>/dev/null |wc -l) NUM_HAM=$(ls ${VAL_HOME}/Maildir/.Learn_NO_Spam/{cur,new}/* 2>/dev/null |wc -l) NUM=$((${NUM_SPAM}+${NUM_HAM})) if [ ${NUM} -gt 0 ] ; then echo "Working on user: ${VAL_USER}" 1>&2 DATE=$(date +"%Y-%m-%d %H:%M:%S") echo -n "${DATE} [${HN}] USER=${VAL_USER}, NUM_SPAM=${NUM_SPAM}, NUM_HAM=${NUM_HAM}" >>${LOG} if [ -d ${VAL_HOME}/Maildir/.Learn_IS_Spam ] ; then LIST_SPAM=$(find ${VAL_HOME}/Maildir/.Learn_IS_Spam/cur -type f -mmin +2 ; find ${VAL_HOME}/Maildir/.Learn_IS_Spam/new -type f -mmin +2) echo -n ", SPAM=" >>${LOG} if [ -n "${LIST_SPAM}" ] ; then for MSG in ${LIST_SPAM} ; do su - ${VAL_USER} -c "sa-learn --spam ${MSG} ; if [ $? -eq 0 ] ; then procmail <${MSG} ; if [ $? -eq 0 ] ; then rm -f ${MSG} ; fi ; fi" done echo -n "scaned" >>${LOG} else echo -n "none" >>${LOG} fi fi if [ -d ${VAL_HOME}/Maildir/.Learn_NO_Spam ] ; then LIST_HAM=$(find ${VAL_HOME}/Maildir/.Learn_NO_Spam/cur -type f -mmin +2 ; find ${VAL_HOME}/Maildir/.Learn_NO_Spam/new -type f -mmin +2) echo -n ", HAM=" >>${LOG} if [ -n "${LIST_HAM}" ] ; then for MSG in ${LIST_HAM} ; do DE=$(date +%s) for CNT in $(seq --equal-width 1 100) ; do if [ ! -f ${VAL_HOME}/Maildir/new/${DE}.${CNT}.${HN} ] ; then su - ${VAL_USER} -c "sa-learn --ham ${MSG} ; if [ $? -eq 0 ] ; then mv -f ${MSG} ${VAL_HOME}/Maildir/new/${DE}.${CNT}.${HN} ; fi" break fi done done echo "scaned" >>${LOG} else echo "none" >>${LOG} fi fi fi fi fi done and a cronjob: [ '/etc/cron.d/check_sa_learn' ] MAILTO=cron */10 * * * *root/home/michelle.konzack/bin/check_sa_learn and works perfectly... on more then 2000 user! Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack c/o Shared Office KabelBW ICQ #328449886 +49/177/9351947Blumenstasse 2 MSN LinuxMichi +33/6/61925193 77694 Kehl/Germany IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: processing of mail considered spam
> Jari Fredriksson wrote: >>> Hi there, >>> Some spam is getting past the spamassassin. So I;d like to devise a scheme where I manually place the emails not caught by spamassass in my >>> 'spam-mail' folder. Is there any way to get spamassassin to process the >>> contents of the folder so I those accepted messages are considered spam >>> in the future? >> It depends. If the "spam-mail folder" is a folder in a POP3 client, it is >> not easy to automate it. if the "spam-mail folder" is a folder in a IMAP-server, and the server uses Maildir format under Linux or other Unix, >> it is easy. The mails are plain text files in the server file system, and >> a cron job can easily run sa-learn --spam with that folder. >> If the server is some MS Exchange I have no idea. Maybe the folder could >> be downloaded periodically with fetchmail or such, and fed to sa-learn. Anyway, SpamAssassin itself does not help besides sa-learn, so this needs >> scripting on your part. > > okay how do I script sa-learn to learn the contents of a particular file. > > Cheers, > > Noah If the user used to call spamc is noah, then this might do it. The last parameter is file name or a folder name, in which case all files in the folder will be learnt. man sa-learn will tell more.. #!/bin/sh /usr/bin/sa-learn -u noah --spam /home/noah/Maildir/spam-mail/cur
Re: processing of mail considered spam
Jari Fredriksson wrote: Hi there, Some spam is getting past the spamassassin. So I;d like to devise a scheme where I manually place the emails not caught by spamassass in my 'spam-mail' folder. Is there any way to get spamassassin to process the contents of the folder so I those accepted messages are considered spam in the future? It depends. If the "spam-mail folder" is a folder in a POP3 client, it is not easy to automate it. if the "spam-mail folder" is a folder in a IMAP-server, and the server uses Maildir format under Linux or other Unix, it is easy. The mails are plain text files in the server file system, and a cron job can easily run sa-learn --spam with that folder. If the server is some MS Exchange I have no idea. Maybe the folder could be downloaded periodically with fetchmail or such, and fed to sa-learn. Anyway, SpamAssassin itself does not help besides sa-learn, so this needs scripting on your part. okay how do I script sa-learn to learn the contents of a particular file. Cheers, Noah
Re: processing of mail considered spam
> Hi there, > > Some spam is getting past the spamassassin. So I;d like to devise a > scheme where I manually place the emails not caught by spamassass in my > 'spam-mail' folder. Is there any way to get spamassassin to process the > contents of the folder so I those accepted messages are considered spam > in the future? > It depends. If the "spam-mail folder" is a folder in a POP3 client, it is not easy to automate it. if the "spam-mail folder" is a folder in a IMAP-server, and the server uses Maildir format under Linux or other Unix, it is easy. The mails are plain text files in the server file system, and a cron job can easily run sa-learn --spam with that folder. If the server is some MS Exchange I have no idea. Maybe the folder could be downloaded periodically with fetchmail or such, and fed to sa-learn. Anyway, SpamAssassin itself does not help besides sa-learn, so this needs scripting on your part.
processing of mail considered spam
Hi there, Some spam is getting past the spamassassin. So I;d like to devise a scheme where I manually place the emails not caught by spamassass in my 'spam-mail' folder. Is there any way to get spamassassin to process the contents of the folder so I those accepted messages are considered spam in the future? Cheers, Noah