We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Forwarding all spam to a single mailbox using SpamAssassin and Qmail

zarko_r
zarko_r asked
on
Medium Priority
1,453 Views
Last Modified: 2013-12-09
Hello all,

I'm trying to get spam under control. The boss has agreed to the following scenario. Any message that gets flagged as spam, from any of our domains, to be forwarded to a "global" spam mailbox.
I have successfully integrated SpamAssassin with Qmail to mark emails as spam. Now I just need some help
with putting them into another mailbox.

What I've done thus far is
rename /var/qmail/bin/qmail-queue to be qmail-queue.orig
made a shell script with the name qmail-queue with just one line
    spamc -f | /var/qmail/bin/qmail-queue.orig

I running on
RHEL 2.6.9-22.EL
SpamAssassin 3.1.9-1
Qmail 1.03
Plesk 8.0.1

Any help, even just advice, would be appreciated.
Comment
Watch Question

Cyclops3590Sr Software Engineer
CERTIFIED EXPERT

Commented:
i probably won't be of much help, because i don't know how qmail works, but the first thing that comes to my mind is procmail.   If you can get the email to be processed by procmail as its being delivered you can have it look at the subject line and see if it was flagged, if so forward it to the spam mailbox, else just deliver it.

keep in mind i haven't used procmail either as i haven't had the need for it yet, but from what i've read, that is one use for it.

Author

Commented:
I can't use procmail because the control panel we use (Plesk) integrates with Qmail. Thanks for the suggestion though.
Cyclops3590Sr Software Engineer
CERTIFIED EXPERT

Commented:
ok, so i take it you don't have command line access to the server then

Author

Commented:
I have full root access. It's a dedicated server for all our small companies. The control panel is used by some of the other people in the company to make minor changes so I can't remove it and do everything manually.
Sr Software Engineer
CERTIFIED EXPERT
Commented:
you shouldn't have to.  have you looked at procmail yet to be sure.  you simply need to have it where qmail uses it for delivering the email to the mailbox instead of it doing that itself.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
Are you using vpopmail?

Here is one I through together for my own system that works fine with vpopmail (if you don't use vpopmail I'll rewrite it otherwise)

put in your .qmail file:
--
|preline /usr/bin/maildrop -w 90 /etc/maildroprc
--


touch /etc/maildroprc
chmod 600 /etc/maildroprc
chown vpopmail:vpopmail /etc/maildroprc (or equivalent)

put the following into your /etc/maildroprc file
--
import EXT
import HOST

SHELL="/bin/sh"
VHOME=`/var/lib/vpopmail/bin/vuserinfo -d $EXT@$HOST`

VPOP="$VHOME/.maildir/"
if ( "no such user" =~ /$VHOME/:d )
{
VDOMHOME=`/var/lib/vpopmail/bin/vdominfo -d $HOST`
VPOP3=`cat $VDOMHOME/.qmail-default | cut -f4 -d' '`
VPOP="$VPOP3/.maildir/"
EXT=`echo $VPOP3|cut -f7 -d'/'`
HOST=`/var/lib/vpopmail/bin/vdominfo -n $HOST`
VHOME=`/var/lib/vpopmail/bin/vuserinfo -d $EXT@$HOST`
}

exception {
include "/var/www/data/${EXT}@${HOST}.mailfilter"
}

# or where ever you want it to go.
if (/^X-Spam-Flag: YES/)
{
        to "$VHOME/Maildir/.advertisements"
}



exception {
to "$VPOP"
}
--

This script will probably not work out of the box for you as you'll need to change the options of where you want to go but.....  it does work.

If you give me more details I can massage it around or you can.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.