***SPAM*** movement

Discussion Room for the Synology MailStation Package
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/su ... p?lang=enu



2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
sygys
I'm New!
I'm New!
Posts: 9
Joined: Thu Mar 21, 2013 7:57 am

***SPAM*** movement

Unread post by sygys » Wed May 08, 2013 10:57 am

Is there an easy way to let messages flagged by the spam filter with ***SPAM*** to be moved the the users junk/spam folder automatically?

Im pretty poor in writing in system files and i really dont want to. but it goes on for months now and synology doesnt seem to give a $%& about it so i need a solution.

And do i have to set all different users or is a few lines of text enough to let it work automatically for new aliasses?

Thanks in advance

zmeel
Student
Student
Posts: 72
Joined: Mon Nov 12, 2012 11:16 am

Re: ***SPAM*** movement

Unread post by zmeel » Wed May 08, 2013 12:53 pm

Hi sygys,
It is relatively simple to have mailed labeled as *****SPAM***** moved to the junk/spam folder.
You have to create two files in the /home directory of each user with some minor code:

-Create a file with the name .forward (including the .) and add the following code:

Code: Select all

|/volume1/@appstore/MailStation/bin/procmail
-Create a file with the name .procmailrc (including the .) and add the following code:

Code: Select all

PATH=/volume1/@appstore/MailStation/bin
VERBOSE=off
MAILDIR=$HOME/.Maildir
DEFAULT=$MAILDIR/
LOGFILE=$HOME/procmail.log
LOCKFILE=$HOME/.lockmail

#### SPAM Handling begin
:0:
* ^X-Spam-Flag: YES
.Junk/

:0:
* ^Subject:.*(*****SPAM*****)
.Junk/
#### Spam handling end
This is how I have my *****SPAM***** labeled mail moved to Junk. It works very well :D

Cheers
Erik
ps If you are not running DSM4 you may have to check the location of the MailStation program.

gwar9999
Trainee
Trainee
Posts: 14
Joined: Wed Jun 19, 2013 10:01 pm

Re: ***SPAM*** movement

Unread post by gwar9999 » Fri Jun 28, 2013 7:17 pm

Thanks zmeel for the solution. Since I had a bunch of users to perform this task on I modified things a bit. You just need to create one script (below), make it executable (chmod 500) and then run it:


spam-to-junk.sh

Code: Select all


if [ "$1" = "" ]
then
  echo "Usage: $0 <username>"
  exit
fi
    
USER=$1
DIR=/volume1/homes/$USER

while true; do
read -p "This will forward all ****SPAM**** to $USER's Junk folder [y/N]: " yn
   case $yn in
       [Yy]* ) break;;
       [Nn]* ) exit;;
   * ) echo "Please answer y(es) or n(o).";;
  esac
done


cat <<'__EOF__' > $DIR/.forward
|/volume1/@appstore/MailStation/bin/procmail
__EOF__

chown $USER:users $DIR/.forward 
chmod 600 $DIR/.forward

cat <<'__EOF__' > $DIR/.procmailrc
PATH=/volume1/@appstore/MailStation/bin
VERBOSE=off
MAILDIR=$HOME/.Maildir
DEFAULT=$MAILDIR/
LOGFILE=$HOME/procmail.log
LOCKFILE=$HOME/.lockmail

#### SPAM Handling begin
:0:
* ^X-Spam-Flag: YES
.Junk/

:0:
* ^Subject:.*(*****SPAM*****)
.Junk/
#### Spam handling end
__EOF__

chown $USER:users $DIR/.procmailrc
chmod 600 $DIR/.procmailrc

This script should be executed as root so that it has access to each home directory. It requires the USERNAME as its only argument and will prompt for confirmation:

Code: Select all

diskstation> ./spam-to-junk.sh bob
This will forward all ****SPAM**** to bob's Junk folder [y/N]: 
Assumptions:
[*] it makes is that the USERNAME actually exists. If not, the script will fail since it won't be able to write the files to the /volume1/homes/non-existent-user directory.
[*] the homes directory is /volume1/homes and each user directory is a child of it.


Hopefully others will find these changes useful.

User avatar
syno_user
Experienced
Experienced
Posts: 129
Joined: Fri Jan 02, 2009 4:31 pm

Re: ***SPAM*** movement

Unread post by syno_user » Wed Jul 10, 2013 1:13 pm

Is this applicable on new DSM 4.3beta?
DS415+ with Synology Remote

KingStepper
Novice
Novice
Posts: 52
Joined: Sun Jan 17, 2010 2:35 am

Re: ***SPAM*** movement

Unread post by KingStepper » Fri Aug 02, 2013 11:11 pm

Thanks from me too zmeel - works a treat.

Tried one of the other solutions on the forum first which ended up in having to re-install DSM. :(

User avatar
fuzzy76
Trainee
Trainee
Posts: 17
Joined: Thu Feb 21, 2013 8:34 pm
Location: Tromsø, Norway
Contact:

Re: ***SPAM*** movement

Unread post by fuzzy76 » Wed Aug 21, 2013 10:09 am

I have MailServer installed, but not MailStation. So there's no procmail on my system. :(

LarryS
I'm New!
I'm New!
Posts: 5
Joined: Sun Sep 01, 2013 4:33 pm
Location: USA

Re: ***SPAM*** movement

Unread post by LarryS » Sun Sep 01, 2013 4:48 pm

Thank you for this workaround! I just set this up on my DS412+ and it is working great. :)

User avatar
lacibaci
Versed
Versed
Posts: 214
Joined: Fri Jan 03, 2014 9:02 pm
Location: Poprad
Contact:

Re: ***SPAM*** movement

Unread post by lacibaci » Sat Feb 01, 2014 6:17 pm

It seems that DSM 4.3 does this by default. Is there a setting somewhere to turn this off? I do want the spam to be marked ****SPAM**** but I don't want it to be moved to .Junk/ directory.

Post Reply

Return to “Mail Station”