• # Pour info

    Posté par . En réponse à la dépêche Reprise de Dspam par la communauté. Évalué à 2.

    J'utilise dspam en complément de postfix et de dovecot en Maildir et imap. J'ai crée un petit script cron qui agit sur deux dossiers, MissedSpam et NotSpam, pour l'apprentissage. Conclusion, c'est efficace, tout enrestant très simple pour les utilisateurs. Le script :
    #!/bin/sh
    # train-spam.sh
    # 
    # Description: Checks each user's /home/Domain/Maildir/.MissedSpam
    # directories to see if the user placed any "missed" spam 
    # messages which got through DSPAM to their INBOX.
    # If there are messages in this directory, then the script
    # invokes sa-learn to update the site-wide tokens to try
    # and improve the defenses for next time...
    #
    # learn_spam - Function which takes a directory and a user as
    # arguments, and then feeds that directory to our anti-spam
    # applications for further SPAM training.
    #
    # Arguments: 
    # 1ドル - Directory name containing SPAM emails. Required
    # 2ドル - User name. If it is not provided, $USER will be used.
    #
    # Example:
    # learn_spam /home/domain/alank/Maildir/.MissedSpam/cur alank
    #
    function learn_spam {
     # loop through all emails in given directory
     for email in $(ls 1ドル); do
     # process SPAM email using DSPAM
     /usr/bin/dspam --mode=teft --source=error --class=spam --feature=chained,noise --user 2ドル < 1ドル/$email
     echo -n "."
     # move SPAM into trash
     mv 1ドル/$email 3ドル
     done # end of email loop
    } # end function learn_spam
    # learn_ham - Function which takes a directory and a user as
    # arguments, and then feeds that directory to our anti-spam
    # applications for further HAM training.
    #
    # Arguments: 
    # 1ドル - Directory name containing HAM emails. Required
    # 2ドル - User name. If it is not provided, $USER will be used.
    #
    # Example:
    # learn_ham /home/domain/alank/Maildir/.NotSpam/cur alank
    #
    function learn_ham {
     # loop through all emails in given directory
     for email in $(ls 1ドル); do
     # process HAM email using DSPAM
     /usr/bin/dspam --mode=teft --source=error --class=innocent --feature=chained,noise --user 2ドル < 1ドル/$email
     echo -n "."
     # move HAM into inbox
     mv 1ドル/$email 3ドル
     done # end of email loop
    } # end function learn_ham
    #
    # Script starts here!
    #
    domain=1ドル
    # loop through all user home directories
    for file in $(ls /home/$domain); do
     # if there is a MissedSpam maildir 
     if [ -d /home/$domain/$file/Maildir/.MissedSpam/cur ]; then
     
     # then process any missed SPAM
     echo -n "Missed spam for $file:"
     learn_spam /home/$domain/$file/Maildir/.MissedSpam/cur $file /home/$domain/$file/Maildir/.Trash/cur 
     learn_spam /home/$domain/$file/Maildir/.MissedSpam/new $file /home/$domain/$file/Maildir/.Trash/new 
     echo ""
     
     fi # end if
     # if there is a NotSpam dir
     if [ -d /home/$domain/$file/Maildir/.NotSpam/cur ]; then
     
     # then process any falsely identified spam, i.e. HAM
     echo -n "False positives for $file:"
     learn_ham /home/$domain/$file/Maildir/.NotSpam/cur $file /home/$domain/$file/Maildir/cur 
     learn_ham /home/$domain/$file/Maildir/.NotSpam/new $file /home/$domain/$file/Maildir/new 
     echo ""
     fi # end if
     echo ""
    done # end for loop
    echo "Done!"
    
    Pour la partie cron :
    #!/bin/sh
    # use maildir folder for spam training
    date=`date +"%d/%m/%y %H:%M"`
    echo -e "\n---$date---" >>/var/log/dspam-train.log
    /usr/local/bin/dspam-maildir-train example.com >>/var/log/dspam-train.log
    /usr/local/bin/dspam-maildir-train mon-domaine.org >>/var/log/dspam-train.log
    exit 0
    
    C'est écris en quirty, mais c'est fonctionnel...