Spam scan for forwarded mail

Discussion in 'Installation/Configuration' started by RicochetPeter, Jul 16, 2006.

  1. RicochetPeter

    RicochetPeter Member

    Hi,

    got another question:

    What would I have to do to let forwarded mail be scanned for spam?
    (With the standard setup, when a mail account is set to be forwarded to one or more external mail addresses, the mails aren't scanned for spam, only the ones that are to be put into a local mail box)
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You will have to change the order of included procmail recipes in the file .procmailrc in the home directory of the mail user so the spam scanning script is in front of the redirection script.

    If you want to change it globally for new users, you will have to modify the template file /root/ispconfig/isp/conf/procmailrc.master
     
  3. RicochetPeter

    RicochetPeter Member

    cool, thanks for the hint.

    this is my .procmailrc:

    Code:
    MAILDIR=$HOME/Maildir/
    DEFAULT=$MAILDIR
    ORGMAIL=$MAILDIR
    
    INCLUDERC=/var/www/web10/user/web10_peter/.mailsize.rc
    ## INCLUDERC=/var/www/web10/user/web10_peter/.quota.rc
    ## INCLUDERC=/var/www/web10/user/web10_peter/.antivirus.rc
    ## INCLUDERC=/var/www/web10/user/web10_peter/.local-rules.rc
    ## INCLUDERC=/var/www/web10/user/web10_peter/.html-trap.rc
    INCLUDERC=/var/www/web10/user/web10_peter/.spamassassin.rc
    ## INCLUDERC=/var/www/web10/user/web10_peter/.autoresponder.rc
    INCLUDERC=/var/www/web10/user/web10_peter/.custproc.rc
    
    actually, in none of the included files (here: .mailsize.rc, .spamassassin.rc, .custproc.rc) there's a rule that forwards the mail :confused: ... so, where does the forwarding take place?

    the .custproc.rc has all my self-made "put mail from xy to folder xy" rules...
     
  4. RicochetPeter

    RicochetPeter Member

    Ah, found it. It's the .forward file in the user's directory. Which process reads it and how do I make it come after the procmailrc? I seem to understand that postfix gives incoming mail to "objects" in the .forward file, which is a comma separated list.

    So the forwarded mail is totally independant of the mail which will be spam scanned and delivered to a mailbox?

    Ideas?
     
    Last edited: Jul 19, 2006
  5. falko

    falko Super Moderator Howtoforge Staff

    You'd have to rewrite the forwarding mechanism so that it uses a procmail recipe instead of the .forward file. In the .forward file you would invoke procmail which then reads the procmail recipes.
     
  6. fobicodam

    fobicodam New Member

    :eek: ok... how it would be in english? (or spanish.. je)
     
  7. falko

    falko Super Moderator Howtoforge Staff

    I don't have such a script at hand right now. You'd have to invent one yourself. ;)
     
  8. RicochetPeter

    RicochetPeter Member

    OK, here's the howto:

    1) Modify /root/ispconfig/isp/conf/procmailrc.master to include a "per-user-procmail" file by adding this line to the end:
    Code:
    INCLUDERC={PMDIR}/.custproc.rc
    You do not have to use ".custproc.rc", chose any file name you like. This will make procmail include every user's custom recipe file.

    2) Delete the forward in the ISPConfig web interface

    3) Add the following to the user's ".custproc.rc" (or whatever name you chose):
    Code:
    :0
    ! [email protected]
    
    Done.
    Like this you can provide accounts that are forwarded, but also spam scanned.

    Another option: if you want to keep a local copy in the user's mailbox, make the first line in the .custproc.rc
    Code:
    :0 c
    The only difference is the "c" after the 0, which make procmail deliver a copy to the remote address, not the mail itself.
     
  9. RicochetPeter

    RicochetPeter Member

    Just out of interest, was this "mini-howto" of any interest to anyone (besides me)? Or is there even a better way to do it?
     
  10. falko

    falko Super Moderator Howtoforge Staff

    Of course! :)
     

Share This Page