Help - Search - Members - Calendar
Full Version: Spamassassin ****SPAM*** into junk folder
The Planet Forums > Control Panels > Plesk
netKudos
Hi,

Is it possible to have spamassassin put all mail it recognises as spam into a seperate folder. I know this is possible using procmail but Plesk mail directories are a bit differant.

Evan
netKudos
anyone?

Please....
jjackson
Was there ever an answer for this?
Gromit
I don't think there's a way to do that with Spamassassin. At least, not with the default Plesk configuration. I've read a few discussions on how to do this with Plesk, but none of them seem to come up with a reasonable solution.
lightning
There is a Spam folder setting in WebMail but it does not seem to work.

The setting is located in Options for Mail - Server and Folder Information. You can also set your Drafts and Trash folder under that option.

Plesk 7.5

Has anyone gotten spam to divert to a folder on the server?
jjackson
I have a working sample of this now but it will be overwritten when a change is made to the mail account from the Plesk interface. I am working on a script that will undo the changes when Plesk make a change.

You will need to have Procmail installed and a valid .procmailrc file.

Here is my script that I run to create the SPAM folder, change the .qmail and copy the .procmailrc file. You will need to update this script to work on your system. I have been using it for a few weeks and there have been no reported trouble. You will need to be root to run this.

Script to create folders and copy files.

call it with parameters of "domain name" "user name"

#!/bin/bash

# creates a spam folder to collect the mail marked as spam

# created by Jay Jackson
# makeitcomplete.com

domainname=$1
username=$2
spamfolderpath="/var/qmail/mailnames/$domainname/$username/Maildir/.SPAM"
qmailpath="/var/qmail/mailnames/$domainname/$username"

echo "Creating spam folder for $username from $domainname"
echo "at $spamfolderpath"

mkdir $spamfolderpath
chown popuser:popuser $spamfolderpath
chmod 700 $spamfolderpath

echo "Copying procmail config file"
cp -f /var/qmail/mailnames/makeitcomplete.com/jjackson/.procmailrc $qmailpath/.procmailrc
chown popuser:popuser $qmailpath/.procmailrc
chmod 700 $qmailpath/.procmailrc

#copy old .qmail
mv -f $qmailpath/.qmail $qmailpath/.qmail.old

sed -e 's/./Maildir//| preline /usr/bin/procmail -p -m .procmailrc/g' $qmailpath/.qmail.
old > $qmailpath/.qmail
chown popuser:popuser $qmailpath/.qmail


Below is my .procmailrc file.

:0:
* ^Subject:.*****SPAM*****
./Maildir/.SPAM/

:0:
*
./Maildir/


You can change this to process mail any want you want. Please keep in mind that this is not fully tested, is not supported and may break Plesk in the future.
thomdf
You'll need to find a program called Maildir, I think its with mailcat or something like that. Check around on the qmail sites.

Modify the default .qmail w/spamassassin on file which looks something like this:

| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -u user@domain.tld -U /tmp/spamd_full.sock > spamcheck$$; if [ -s spamcheck$$ ]; then /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "" "" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; retval=$?; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $retval; fi; rm -f spamcheck$$; fi # ACCEPT UCE
| true
./Maildir/

to something like this for each user:


|/usr/local/psa/bin/psa-spamc -u user@domain.tld -U /tmp/spamd_full.sock > spamcheck$$; export SPAM=`grep -c -i "^X-Spam-Status: Yes" spamcheck.$$`; if [ "$SPAM" == "1" ]; then cat spamcheck.$$ |/usr/local/bin/maildir ./Maildir/.SPAM/; fi; if [ "$SPAM" == "0" ]; then cat spamcheck.$$ |/usr/local/bin/maildir ./Maildir/; fi; rm -f spamcheck.$$
|true;


The user needs to have a .SPAM folder created already, similar to jjacksons example but procmail isn't required. Plesk overwrites this .qmail if the user or admin makes settings changes to their delivery options. I think plesk has an E-mail api that you can hook and do modifications like auto fix this .qmail file to the modified version after a settings change but I never got that much into it.
this.is.eboy
Hi,

I read your post at http://forums.ev1servers.net/showthread.php?t=55867 with the following script.


|/usr/local/psa/bin/psa-spamc -u user@domain.tld -U /tmp/spamd_full.sock > spamcheck$$; export SPAM=`grep -c -i "^X-Spam-Status: Yes" spamcheck.$$`; if [ "$SPAM" == "1" ]; then cat spamcheck.$$ |/usr/local/bin/maildir ./Maildir/.SPAM/; fi; if [ "$SPAM" == "0" ]; then cat spamcheck.$$ |/usr/local/bin/maildir ./Maildir/; fi; rm -f spamcheck.$$
|true;

I tried but it failed. Are you sure that your script is correct? /usr/local/bin/maildir is not a command in my system in Plesk.

Kenneth
this.is.eboy
hi thomdf,

i read again your post and notice your mentioning "maildir" command. what can i do to move tagged mails to .SPAM folder if my system does not have either "maildir" and "procmail"?

if i change the setting in plesk to delete spam mails, the following .qmail script is generated.

| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -u spam@mydomain.com -U /tmp/spamd_full.sock -E > spamcheck$$; check=$?; if [ -s spamcheck$$ ]; then if [ $check = 1 ]; then retval=99; else /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "" "" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; retval=$?; fi; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $retval; fi; rm -f spamcheck$$; fi # REJECT UCE
| true
./Maildir/

i am not good at linux. is it possible to modify the above script to move tagged mails to .SPAM folder instead of deleting them?

with many thanks
kenneth
jjackson
Maildir is not a program it is the directory that the message is moved to. More details about what you are running would be helpful.
this.is.eboy
hi jjackson,

i tried to run thomdf's script shown above, which does not required procmail, but a command named "maildir'. anyway, it won't work.

instead of using procmail, can i just edit .qmail to move messages to a different folder?

your help is appreciated!

kenneth
jjackson
I have not eve looked at the other script in this post. We are using the one thatr I posted.
coreyti
Hi all,

Here's a technique to handle the issue without procmail or maildir. I am using qmail-local with flags to pass handling logic to specific .qmail-xxx files. This works without any issue from the user's perspective, though I am getting an error in the qmail log (see below). If anyone can help with that, I'd appreciate it.

Notes:
1) I am using folders named ".Junk" rather than ".Spam"
2) I have only tried this on a per-user basis so far... not sure if it would work for an entire domain
3) Be sure ownershiop and permissions are correct for the additional files (chmod 600 .qmail-*)

file: /var/qmail/.../user/.qmail
----------
CODE
| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -u user@domain.tld -U /tmp/spamd_full.sock -E > spamcheck$$; check=$?; if [ -s spamcheck$$ ]; then if [ $check = 1 ]; then /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "-" "junk" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; else /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "-" "clean" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; fi; retval=$?; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $retval; fi; rm -f spamcheck$$; fi # REJECT UCE

| true

./Maildir/



file: /var/qmail/.../user/.qmail-clean
----------
CODE
./Maildir/



file: /var/qmail/.../user/.qmail-junk
----------
CODE
./Maildir/.Junk/



Log error...
Sep 8 14:07:52 host qmail: 1157749672.885793 delivery 41: success: Get_mailbox_size_error:_unable_to_get_size_of_subdir_in_mail_user_home_dir(please_report_about_to_development_group).//Get_mailbox_size_error:_unable_to_get_size_of_subdir_in_mail_user_home_dir(pleas
e_report_about_to_development_group).//did_1+0+0/did_0+0+1/


Cheers,
Corey
coreyti
Change user@domain.tld to $RECIPIENT

- Corey
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.