Preconfigured spam settings

GregBeason

Verified User
Joined
May 4, 2006
Messages
7
We have recently been upgrading our DA server to make our client's initial setup much easier, particularly in email spam settings. DA does not provide any means to preconfigure spam settings (spam destination, score levels, junk email location, etc). We have configured post install scripts for user, domain and email (see below) to configure out desired default settings. Everything works wonderfully as the end user doesn't have to enable spam filtering and has their email put in their junk email folder.

We did choose to break from the INBOX.spam folder, which is giving us some grief. With the new RoundCube, we found it easier on end-users to have their Junk E-mail labeled as such (similar to MS Outlook which most of users current use), and for it to not be under inbox. Also, for customers using IMAP, Outlook's internal SPAM filtering uses the same folder. The problem we are having is that whenever as user changes the spam settings, DA recreates the INBOX.spam. Is there any setting to choose the SPAM folder that is created to store spam?

We have utilized post install scripts as follows:

/usr/local/directadmin/scripts/custom/domain_create_post.sh
#!/bin/sh
DIR=/etc/virtual/$domain
HOME=/home

echo "where=userspamfolder" > $DIR/filter.conf
chown mail.mail $DIR/filter.conf
chmod 600 $DIR/filter.conf


echo "# Exim Filter

# created by DirectAdmin, version 1.28.1
# Do not modify this file as any changes will be
# overwritten when the user makes a change.
# (data is only written to this file, not read)

if error_message then finish endif





if
\$h_X-Spam-Status: contains \"Yes\"
then
if
$local_part is \"$username\"
then

save \"$HOME/$username/Maildir/.Junk E-mail/new/\" 660
else
save \"$HOME/$username/imap/\$domain/\$local_part/Maildir/.Junk E-mail/new/\" 660

endif
finish
endif


#end filter

" > $DIR/filter
chown mail.mail $DIR/filter
chmod 600 $DIR/filter

echo "Configured SPAM filter configuration sucessfully"



exit 0;


/usr/local/directadmin/scripts/custom/user_create_post.sh
#!/bin/sh
if [ "$spam" = "ON" ]; then
DIR=/home/$username/.spamassassin
mkdir $DIR
cp /usr/local/directadmin/scripts/custom/user_prefs.default $DIR/user_prefs
chown ${username}:mail $DIR
chmod 771 $DIR
chown $username:$username $DIR/user_prefs
chmod 755 $DIR/user_prefs
touch $DIR/spam
chown mail:$username $DIR/spam
chmod 660 $DIR/spam
fi
exit 0;

/usr/local/directadmin/scripts/custom/user_prefs.default
required_score 3.0



report_safe 0


/usr/local/directadmin/scripts/custom/email_create_post.sh
#!/bin/sh
HOME=/home

mkdir $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/
mkdir $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/new
chown $username.mail -R $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/
chmod 770 -R $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/

rm -rf $HOME/$username/imap/$domain/$user/Maildir/.INBOX.spam
echo "Junk E-mail" > $HOME/$username/imap/$domain/$user/Maildir/subscriptions


echo "Junk Email folder created"



exit 0;

Also, does anyone know how to create the filer.conf based on the template in the data directory?
 
I have to agree this makes much more sense. How does this work in squirrelmail?
 
It should work great. This is at the server level, so squirrel should just open the boxes right up. I have updated the scripts since I posted and will put them up again soon. THe only problem i have so far is that when a user changes the spam from Quarantine to inbox and back, it adds the .INBOX.spam.
 
domain_create_post.sh

#!/bin/sh
DIR=/etc/virtual/$domain
HOME=/home

echo "where=userspamfolder" > $DIR/filter.conf
chown mail.mail $DIR/filter.conf
chmod 600 $DIR/filter.conf


echo "# Exim Filter

# created by DirectAdmin, version 1.28.1
# Do not modify this file as any changes will be
# overwritten when the user makes a change.
# (data is only written to this file, not read)

if error_message then finish endif





if
\$h_X-Spam-Status: contains \"Yes\"
then
if
\$local_part is \"$username\"
then

save \"$HOME/$username/Maildir/.Junk E-mail/new/\" 660
else
save \"$HOME/$username/imap/\$domain/\$local_part/Maildir/.Junk E-mail/new/\" 660

endif
finish
endif


#end filter

" > $DIR/filter
chown mail.mail $DIR/filter
chmod 600 $DIR/filter

echo "Configured SPAM filter configuration sucessfully"



exit 0;

email_create_post.sh

#!/bin/sh
HOME=/home

mkdir $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/
mkdir $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/new
chown $username.mail -R $HOME/$username/imap/$domain/$user/Maildir/

rm -rf $HOME/$username/imap/$domain/$user/Maildir/.INBOX.spam
rm -rf $HOME/$username/imap/$domain/$user/Maildir/subscriptions

echo "Junk E-mail" > $HOME/$username/imap/$domain/$user/Maildir/subscriptions
chmod 770 -R $HOME/$username/imap/$domain/$user/Maildir/.Junk\ E-mail/

echo "Junk Email folder created"



exit 0;

user_create_post.sh
#!/bin/sh
if [ "$spam" = "ON" ]; then
DIR=/home/$username/.spamassassin
mkdir $DIR
cp /usr/local/directadmin/scripts/custom/user_prefs.default
$DIR/user_prefs
chown ${username}:mail $DIR
chmod 771 $DIR
chown $username:$username $DIR/user_prefs
chmod 755 $DIR/user_prefs
touch $DIR/spam
chown mail:$username $DIR/spam
chmod 660 $DIR/spam
fi
exit 0;
user_prefs.default
required_score 3.0



report_safe 0
 
"THe only problem i have so far is that when a user changes the spam from Quarantine to inbox and back, it adds the .INBOX.spam."

This is a problem. Maybe DA staff would have an idea for you. Maybe DA can simply put a parameter in the directadmin.conf so that we can simply tell it to go where we want? Have you asked them?
 
i have problems with spamassassin...

i have it running, in my exim logs, SA is searching and founding SPAM, and sending to ... /imap/DOMAIN/Maildir/...

but my problem is that accounts on rounducbe (i've only roundcube installed) don't see that directory...
only the one in /home/USER/Maildir/... (the one configured in Dovecot)

anyone knows how to correct this... i would like to have it working the way DA recomends...

i know that deleting that if statement and sending the spam to the same folder would resolve the problem but... is there any other solution/fix to this?

anyone with the same problem ?
 
User Level login » domain » Email Menu » Spamassassin Setup

- Where do you want the spam to go?
-> Send the spam to appropriate user's spam folder.
 
1) I have two email accounts 'client1' and client2' on the same domain.com .

2) I have a forwarder 'client1-fw' pointing to [email protected]

3) All spam sent to [email protected], should be sent to client1 spambox. (and it's working)

4) all spam sento to [email protected], should be sent to client2 spambox. (and working)

5) all spam sent to [email protected], should be sent to client1 SPAMBOX.

and not to /home/USER/imap/DOMAIN.com/client1-fw/Maildir/.INBOX.spam/new , cos [email protected] does not login to roundcube, it's a forwarder, and client1 login can't see that forwarder folder inside roundcube...

any help on this ?


thanks in advance
 
to be honest i don't know if this server in the default state i got this administration from other sysadmin...

under spamassassin setup (in DA) i've

"Send the spam to the appropriate users's spam folder."

if this is the default then i believe yes.
 
By default SA is disabled for new accounts.

If you followed instructions from the starting post, then it goes with "Send the spam to the appropriate users's spam folder."
 
Are those scripts still valid?

And should i ask why send to .Junk and not to .INBOX.Spam?

Webmail system will not recognize it or there is another reason?

Thanks
 
Why not? Seems to be working, but I did not verify.

And should i ask why send to .Junk and not to .INBOX.Spam?

You can change it. The topic starter gives answer in his message:

We did choose to break from the INBOX.spam folder, which is giving us some grief. With the new RoundCube, we found it easier on end-users to have their Junk E-mail labeled as such (similar to MS Outlook which most of users current use), and for it to not be under inbox. Also, for customers using IMAP, Outlook's internal SPAM filtering uses the same folder. The problem we are having is that whenever as user changes the spam settings, DA recreates the INBOX.spam.
 
Thanks for your reply.

Well my doubt is cause is an old post so i dont know if directadmin implemented/changed the way to do this :)

And im also worried cause for all user already on the system that have to be done manually for each domain/email.

Another thing ive always asked myself is why all the imap directory are under inbox and not as an usual standard structure, but, well maybe there is a valid reason
 
Ok, if you want your new users to have pre-configured SA, you can copy user_prefs with desired settings (not necessary those from the first message). Just set SA as you wish in Directadmin, then copy it to /usr/local/directadmin/scripts/custom/user_prefs.default, from where it will be copied to a new user.

See http://help.directadmin.com/item.php?id=117 and notes

The above script can be used to also enable spamassassin for all existing accounts. You can create another simple script to do it called (for example) spam.sh with the following code...
 
Thanks for the link, i had already done this for enable the SA with my defined prefs to each user.

I would take advantage of your avaiblity (dunno if is correct english :P) for ask, if you know, if when you perform admin backup for user "admin", it will backup custom scripts present in /usr/local/directadmin/script/custom and in custombuild/custom

If not, i think im gonna make a script to save those settings and import each time i setup a new box (im trying to do a script that do all the work for me, and i need to learn how to make a good centos kickstart cd for that too)

As always, thanks for help
 
No, with reseller level backups nothing from custom scripts is added. You can use system backups or write script, as you've already mentioned.
 
Back
Top