Find the answer to your Linux question:
Results 1 to 6 of 6
We are running Sendmail 8.12.8 and SpamAssassin on a RH8 box for about 50+ users. What can we use to go ahead and reject or automatically delete email marked as ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2004
    Posts
    5

    Anti-SPAM Software


    We are running Sendmail 8.12.8 and SpamAssassin on a RH8 box for about 50+ users.

    What can we use to go ahead and reject or automatically delete email marked as SPAM by SpamAssassin...?

    We looked at a product called MimeDefang, but it was quite complicated, and it will need a 5th pass to get it going...

    Any help much appreciated !

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That's really easy. Just add a procmail recipe that reads something like this:
    Code:
    :0
    *X-Spam-Flag: YES
    /dev/null
    The system-wide procmailrc file is /etc/procmailrc.

  3. #3
    Just Joined!
    Join Date
    Jan 2004
    Posts
    5

    Thanks

    Thanks, I'll experiment with this.

  4. #4
    Just Joined!
    Join Date
    Jan 2004
    Posts
    5

    Anti-SPAM Handling

    About Sendmail:

    Instead of deleting the email marked as SPAM by Spamassassin, what if I wanted to send it to a special folder - and *delete* the email there after say 30 days ?

    Thanks for the procmail commands, it has opened up a whole new world... sending Spam email to the special folder seems stragihtforward, but automatically deleting it isnot immediately apparent to me.

    Thanks in advance!

  5. #5
    Linux User
    Join Date
    Jun 2003
    Location
    Calgary, AB CANADA
    Posts
    496

    Re: Anti-SPAM Handling

    Quote Originally Posted by arthur77
    About Sendmail:

    Instead of deleting the email marked as SPAM by Spamassassin, what if I wanted to send it to a special folder - and *delete* the email there after say 30 days ?
    A very good idea. We recently implemetted an anti-spam app on our mail server at work, and I get a lot of personal mail from friends come to me as spam. Just something to watch out for...
    \"Everything should be made as simple as possible, but not simpler.\"
    Albert Einstein

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That would be quite easy to do with a maildir folder instead of a mbox folder. Try this procmail recipe:
    Code:
    :0
    *X-Spam-Flag: YES
    /var/spool/spamdir/
    (You have to manually create the /var/spool/spamdir directory)
    Note the ending slash at /var/spool/spamdir/. That tells procmail to use the maildir format instead of mbox. In a maildir folder, all messages are stored in directories in seperate files - that is, one file per message. Then you could rather easily create a C program that runs every day from cron and checks the mtime of the messages and deletes them when they're old enough, something like this:
    Code:
    #include <sys/stat.h>
    #include <unistd.h>
    #include <dirent.h>
    #include <stdio.h>
    #include <time.h>
    
    void clean&#40;char *path&#41;
    &#123;
        DIR *dir;
        struct dirent *de;
        struct stat sb;
        time_t now;
        
        time&#40;&now&#41;;
        if&#40;chdir&#40;path&#41; || &#40;&#40;dir = opendir&#40;"."&#41;&#41; == NULL&#41;&#41;
        &#123;
            perror&#40;path&#41;;
            return;
        &#125;
        while&#40;&#40;de = readdir&#40;dir&#41;&#41; != NULL&#41;
        &#123;
            if&#40;stat&#40;de->d_name, &sb&#41;&#41;
            &#123;
                perror&#40;de->d_name&#41;;
                continue;
            &#125;
            if&#40;sb.st_mtime < now - &#40;3600 * 24 * 30&#41;&#41;    /* Appr. one month */
            &#123;
                if&#40;unlink&#40;de->d_name&#41;&#41;
                    perror&#40;de->d_name&#41;;
            &#125;
        &#125;
    &#125;
    
    int main&#40;int argc, char **argv&#41;
    &#123;
        clean&#40;"/var/spool/spamdir/cur"&#41;;
        clean&#40;"/var/spool/spamdir/new"&#41;;
    &#125;
    Note that I haven't tried this program, so surely there's a typo somewhere.

    I wanted to do a shell script instead, but I couldn't think of a good way to find out if a file was older than a month. Anyone?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •