Move Mails with dovecot-sieve

Status
Für weitere Antworten geschlossen.

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
so the filename should be .dovecot-sieve. instead of .dovecot-sieve?
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
ok, yes the wiki is wrong then :)

Right, changed it and the spam is still coming into inbox but there is a new file generated in the home directory now automatically?

Rich (BBCode):
NAS> dir
total 20
drwxr-xr-x  3 UserA users 4096 May 24 21:55 .
drwxr-xr-x 15 root  root  4096 May 18 12:34 ..
drwx------ 13 UserA users 4096 May 24 21:55 .Maildir
-rw-r--r--  1 UserA root   303 May 24 21:40 .dovecot.sieve
-rw-------  1 UserA users  280 May 24 21:55 .dovecot.sievec
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
This new File means that dovecot-sieve works now. So then the path must be wrong. And make .dovecot.sieve chmod 0700 Sure you have to correct destination in the file?
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
chmod 0700 .dovecot.sieve
Rich (BBCode):
NAS> chmod 0700 .dovecot.sieve
NAS> dir
total 20
drwxr-xr-x  3 UserA users 4096 May 24 21:55 .
drwxr-xr-x 15 root  root  4096 May 18 12:34 ..
drwx------ 14 UserA users 4096 May 24 22:01 .Maildir
-rwx------  1 UserA root   303 May 24 21:40 .dovecot.sieve
-rw-------  1 UserA users  280 May 24 21:55 .dovecot.sievec

.dovecot.sieve file
Rich (BBCode):
equire "fileinto";
if header :comparator "i;ascii-casemap" :contains "subject" "*****SPAM*****" {
  fileinto ".Trash";
  stop;
} elsif header :comparator "i;ascii-casemap" :contains "from" "info@synology-forum.de" {
   fileinto "INBOX.Computer &- Security.Foren.Synology";
   stop;
} else {
   keep;
}

Still into Inbox :(
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
And the testmail is definetly coming for UserA@yourdomain.tld? You login as UserA to check the mailbox?
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
I use virtual alias users as I host more than one domains email.

so for example

john@homedomain.com john-home (Unix account)
john@workdomain2.com john-work (Unix account)

This is the guide I followed to setup virtual users for multiple domains.

Rich (BBCode):
2. vi main.cf
3. Add this line at end:

virtual_alias_maps=hash:/usr/syno/mailstation/etc/virtual

4. Select virtual:
You can list any mail address to any username!

your_domain1.dk anything
tom@ your_domain1.dk TomPrivate
birthe@ your_domain1.dk BirthePrivate

your_domain2.dk anything
tom@ your_domain2.dk TomWork
birthe@ your_domain2.dk BirtheWork

5. Next you need to compile this file into virtual.db. Login with the PuTTYtel as: User=root, Password=your admin password.
6. Write this: /usr/syno/mailstation/sbin/postmap /usr/syno/mailstation/etc/virtual
7. Check it: cd /usr/syno/mailstation/etc
8. Write: dir
9. Now a virtual.db should be available on the server.
10. Now you need to restart the postfix program:

/usr/syno/mailstation/sbin/postfix stop
/usr/syno/mailstation/sbin/postfix start

11. Now you are done however please allow up to 1 minute before postfix is updated.

If you later change something in the “virtual”, remember to recompile it (step 6).

Also remember if you update the mailstation package or update the Diskstation OS it will overwrite any edits you made before. Backup your files!
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
ah then the virtual user might be the problem. The steps from your description above implement virtual users for Postfix (smtp). But deliver is dovecot. So I think your dovecot still runs with real (local) users. Have you implemented virtual users in dovecot too? (http://syno.brain-force.ch/virtual_users_for_dovecot)
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
In the end the setup of virtual users in dovecot makes virtual users in postfix un-necassary. At the end postfix will ask dovecot for authentication of a user. And in the answer of this request postfix is told where the mailbox of this virtual user is. So you can remove virtual Users from postfix and do all via dovecot. Only one place to config the users ;-)
Yes you can leave the getmail part aside again
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
ok thanks. I'm actually quite worried because these mail accounts are live and im scared about messing up! I may try to do this or I may give up and wait for a synology approved solution. I haven't decided yet. :(

I'm worried about this part mainly, as I don't want to move userhomes and the part with vmail. :(

Rich (BBCode):
create virtual users

To create virtual users you should install dovecotpw as well. It's sources are in src/util (or see alternative below)

make install dovecotpw

and copy the files created into a folder within PATH.
After that the following command creates a user user@domain.tld with password totalSecret hashed with a SSHA in given file

echo user@domain.tld:$(dovecotpw -p "totalGeheim" -s SSHA) >> /opt/etc/dovecot/passwd

After that you'll have to create the following directories

mkdir -p /volume1/homes/vmail/domain.tld/user/.Maildir
chown -R vmail:vmail /volume1/homes/vmail
chmod -R g-rwx,o-rwx /volume1/homes/vmail

An alternative to compiling dovecotpw from source would be the following steps

mkdir /volume1/public/tmp
cd /volume1/public/tmp
ipkg download dovecot
mv dovecot_1.2.0.beta1-2_powerpc.ipk dovecot_1.2.0.beta1-2_powerpc.tar.gz
tar xvzf dovecot_1.2.0.beta1-2_powerpc.tar.gz
tar xvzf data.tar.gz
cp ./opt/sbin/dovecotpw /usr/syno/mailstation/libexec/dovecot/
rm -R /volume1/public/tmp
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
you can use virtual user in postfix as well together with virtual users in dovecot. That way you don't have to remove the config from postfix. In that case postfix would still do the virtual stuff and give the mail to deliver which does it's own virtual stuff. They can co-exist ;-)
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
one thing that might work without installing virtual users in dovecot is to change the command for deliver in main.cf to
Code:
[FONT=monospace]
[/FONT]/usr/syno/mailstation/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
but I'm actually not sure if this can work in main.cf.
Don't forget to restart your postfix after changing the config
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
I will have a think about it, I'm not sure. Thank you for all your help!
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
np, glad to help ;-)
Just to confirm: I use dovecot and postfix for quite a long time with virtual users only from dovecot. No problem with dovecot-sieve or deliver. They really work fine together. Although is a bit an effort to achive, it's worth it because its very flexible :)

Greets

tobi
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
Hello, I tried this amendment

Rich (BBCode):
/usr/syno/mailstation/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

in main.cf but all mail ceased to work. Changed back now. Thanks for the possible answer though.
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
if the line above did not work then you could try the following

/usr/syno/mailstation/libexec/dovecot/deliver -f ${sender} -d ${user}
leave out the nexthop. That way postfix should translate the email user to respective local user and give this information with the -d ${user} to deliver. If I were you I would give this line above another try.
One other thing that came in my mind yesterday before sleeping: It can be tremendous helpful to install an alternative login service. ipkg syslog-ng logs really every message. This is especially helpful to trace down problems with the mailserver-processes. I have a description in my wiki about installing syslog-ng in english. If you tranfer just one message with syslog-ng you will receive more log lines than the synology log logs during the entire bootproccess ;-)
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
Hello, tried that code for mailbox_command and reload postfix. Mail is delivered fine but *****SPAM***** is still not filtered. :(
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
@Spuddy
then I don't know what else to try to find where the error is. If you have some time then I really would suggest the installation of an alternative logging-service. syslog-ng prints out messages that the default service never would. I never saw a better tool to debug such strange mailserver behaviour.
 
Status
Für weitere Antworten geschlossen.
 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat