Redirecting spam with procmail

Discussion in 'Server Operation' started by AlArenal, Nov 6, 2007.

  1. AlArenal

    AlArenal New Member

    Hi!

    I'm trying to get this setup to work:

    I use a standard ISPConfig installation and so I use postfix, spamassassin over procmail, etc. I created an email account [email protected] and added the following code to my spamassassin.rc.master file. Afterwards I changed my accounts so the config got regenerated and reflected my changes in the user's local .spamassassin.rc . Here's my code snippet:

    Code:
    :0:
    * ^TO_.*@mydomain.tld
    * !^X-Loop: [email protected]
    * ^X-Spam-Status: Yes
    | formail -A "X-Loop: [email protected]" | \
      /usr/sbin/sendmail -oi [email protected]
    This code works, meaning all mail that gets marked as spam by spamassassin also gets redirected to [email protected]. However there is one drawback:
    The mails in my spam account contain the original mail (as returned by spamassassin) several times attached to itself (maybe some 50 times or so). It looks pretty strange and I don't see why this happens.

    Can anyone please turn on the light for me?

    P.S.:
    It seems the mails get checked by spamassassin over and over again until finally they're to big (>256k) to be handled.
     
    Last edited: Nov 6, 2007
  2. AlArenal

    AlArenal New Member

    I should have thought about a minute later ;)

    It's now clear that with the standard procmail recipe every mail gets scanned by spamassassin first before further evaluation is done. So there's my loop. I'm just curious whether or not it's sufficient to change this...

    Code:
    * < 256000
    | /home/admispconfig/ispconfig/tools/spamassassin/usr/bin/spamassassin --prefs-file=/var/www/myweb/user/myuser_spam/.user_prefs
    into that:

    Code:
    * < 256000
    * !^X-Spam-Status: Yes
    | /home/admispconfig/ispconfig/tools/spamassassin/usr/bin/spamassassin --prefs-file=/var/www/myweb/user/myuser_spam/.user_prefs
     
  3. matiasCU

    matiasCU Member

    Domain variable

    Hi AlArenal:
    Could you tell me how to include the domain name in the file spamassassin.rc.master?
    Its posible to use some variable in the spamassassin.rc.master to return the value of the domain to which the user? Eg spam@VARIABLE
    I was trying with {DOMAIN}, but apparently not under the environment of users.

    Thanks in advance.
     
  4. AlArenal

    AlArenal New Member

    Hi matiasCU,

    I just hardcoded some passages in customized_templates/spamassassin.rc.master because I didn't want to redirect spam for each and every domains' mail account.

    To redirect spam for every account of a domain:

    Code:
    #:0:
    * ^TO_.*@domain.tld
    * !^X-Loop: [email protected]
    * ^X-Spam-Status: Yes
    | formail -A "X-Loop: [email protected]" | \
      /usr/sbin/sendmail -oi [email protected]
    
    Because you can use regular expressions you have at least some flexibility defining addresses and domains, ...
     
  5. matiasCU

    matiasCU Member

    Solution

    First of all thanks to Al.
    My Requirement:
    I needed to redirect spam to an account [email protected], but also needed to make one copy of the user spam folder, so I did the following:

    In /root/ispconfig/isp/conf/spamassassin.rc.master:
    Change this lines:
    :0fw
    * < 256000
    | {SPAMASSASSIN_PATH} --prefs-file={PREFS_FILE}

    To this:
    :0fw
    * < 256000
    * !^X-Spam-Status: Yes
    | {SPAMASSASSIN_PATH} --prefs-file={PREFS_FILE}

    And add this lines:
    # For copy spam message in user Spam folder
    :0 c
    * ^X-Spam-Status: Yes
    $MAILDIR/.Spam/

    # And to forward spam message to [email protected]
    :0:
    * !^X-Loop: [email protected]
    * ^X-Spam-Status: Yes
    | formail -A "X-Loop: [email protected]" | \

    ...and that's all old!
     
  6. mehulved

    mehulved New Member

    Thank you MatiasCU and AlArenal. I was looking for the solution too. Works nicely :)
     

Share This Page