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
Hallo,

Ich entschuldige mich für mein schreckliches Deutsch. Ich versuche, eine automatische Umsetzung von E-Mails verschieben markiert ***** SPAM *****. Ich habe versucht nach dieser Anleitung unten

http://syno.brain-force.ch/install_dovecot_sieve_eng

Aber es ist nicht funktioniert, ist E-Mail nicht automatisch auf Spam-Ordner verschoben noch. Vielleicht könnte jemand mir helfen. Wenn Sie Englisch sprechen können sogar noch besser! Ich brauche wirklich dieses umgesetzt, wie ich etwa 5 Domains und virtuelle Nutzer haben, und wir bekommen viele Spam. Ich bin mit einem DS1010 +.

Mai kann jemand in meine Box SSH auf einen Blick zu haben?

Dank
 

jahlives

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

sorry for my english ;-) It's a little bit complicate to help if we have to guess where you might stuck. Could you tell the steps that you did? Otherwise is just wild-guessing what happend on your DS. The error could be in the build process of dovecot-sieve or just a "simple" misconfiguration. Did you check the logs? They are at /var/log/messages for the system log files. furthermore dovecot-sieve holds an own log file. This is a file in the homedirectory of the user running dovecot. afaik it's called .dovecot.err This file would show possible configuration errors by your sieve-script
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
Hallo jahlives,

Ich habe dich auf skype hat, hoffentlich nichts dagegen mit 10 Minuten Ihrer Zeit, mir zu helfen mit diesem lästigen Problem!

Dank
 

jahlives

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

the problem is that such a problem is most probably not solved in just 10 minutes. I will help you here in the forum, but I do not perform private support via skype or email. We are a community forum and DO NOT work for Synology, therefore we do all this in our free time and without payment. So I hope you can understand that I only help via the forum.
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
ok, no problem. My first question, where is the rc file for getmail, is there just one rc file or do all users and virtual users have an rc file? I am trying to implement this part.

Integration in getmail

To involve the LDA (and it's filter rules) when mails are loaded from external accounts (ex with getmail), you'll have to amend your rc-files accordingly. Normally getmail writes mails directly into the given mailboxes, so we have to „tell“ getmail to involve the LDA

[destination]
type = MDA_external
path = /usr/syno/mailstation/libexec/dovecot/deliver
arguments = ("-e", )

That works fine for local users. But if you want to have virtual users have a look at the following discussion

Thanks
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
every virtual User should have his/her own rc Files. rc Files are per external account. So if you have 5 external accounts you should have 5 rc files for getmail. But big question: Do you use getmail at all?
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
I have basically installed the synology mailstation2 app, started hosting 5 email domains. Then I have started this guide. If getmail isn't default in the mailstation, no I do not? Can this work if I don't use getmail? If I'm not using getmail, what is the default setup using?
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
Yes getmail is not part of the firmware. That's an ipkg package. dovecot-sieve does work without getmail as well. To do that you need to "tell" postfix (the smtp server) that it should use the dovecot deliver process to deliver mails to mailboxes (see http://syno.brain-force.ch/install_dovecot_sieve_eng#integration_in_postfix) Just leave out getmail if you have no getmail installed. But you must have compiled dovecot-sieve and deliver from sources. Otherwise it won't ever work ;-)
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
ok, so i do not need getmail to automatically move *****SPAM*** email to spam folder? I do not need to configure any rc files?
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
ok, so i do not need getmail to automatically move *****SPAM*** email to spam folder? I do not need to configure any rc files?
Yes correct it's not necessary for dovecot-sieve to have getmail present in the system. I just wrote about it in my wiki, because most users want their DS to collect their mails from external account. Just for that getmail is necessary
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
Yes correct it's not necessary for dovecot-sieve to have getmail present in the system. I just wrote about it in my wiki, because most users want their DS to collect their mails from external account. Just for that getmail is necessary

Thanks for clarifying that. So I have followed the guide except for the getmail intergration. ****SPAM***** is still being delivered to inbox.

/var/log/messages has only three lines regarding dovecot. They were yesterday.

Rich (BBCode):
May 23 20:19:35 dovecot: Killed with signal 15
May 23 20:55:54 dovecot: Killed with signal 15
May 23 21:09:19 dovecot-auth: pam_unix(dovecot:auth): check pass; user unknown

I cannot find a .dovecot.err in the users home directory?

Rich (BBCode):
NAS> cd /volume1/homes/UserA/
NAS> dir
total 16
drwxr-xr-x  3 UserA users 4096 May 24 20:19 .
drwxr-xr-x 15 root  root  4096 May 18 12:34 ..
drwx------ 13 UserA users 4096 May 24 20:26 .Maildir
-rw-r--r--  1 root  root   303 May 24 20:19 .dovecot-sieve

Thanks for your help I apprieciate it.
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
have you performed the changes to the dovecot.conf File? if you cannot find the dovecot.err File this means that there is no error in the sieve File (at least no synthax error ;-) ) Can you show me the content of the dovecot.sieve file? Just blank out personal data
And make UserA the owner of the sieve File
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
have you performed the changes to the dovecot.conf File? if you cannot find the dovecot.err File this means that there is no error in the sieve File (at least no synthax error ;-) ) Can you show me the content of the dovecot.sieve file? Just blank out personal data
And make UserA the owner of the sieve File

Hi, I have changed the owner to UserA. Here is the .dovecot-sieve file, exactly the same as the guide except Junk instead of Trash.

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

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
if and elsif should be on one line. Otherwise your file looks good. So now we have to go backwards ;-) Did you make all the changes to dovecot.conf? Did you change main.cf of postfix? Were there any errors while compiling deliver and dovecot-sieve? Did you copy the dovecot-sieve Files and deliver to the correct directories?
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
if and elsif should be on one line. Otherwise your file looks good. So now we have to go backwards ;-) Did you make all the changes to dovecot.conf? Did you change main.cf of postfix? Were there any errors while compiling deliver and dovecot-sieve? Did you copy the dovecot-sieve Files and deliver to the correct directories?

I have amended the .dovecot-sieve file to.

Rich (BBCode):
require "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;
}

dovecot.conf

Rich (BBCode):
protocol lda {
  # Address to use when sending rejection mails.
  postmaster_address = spam@mydomain.com

  # Hostname to use in various parts of sent mails, eg. in Message-Id.
  # Default is the system's real hostname.
  hostname = mydomain.com

  # Support for dynamically loadable plugins. mail_plugins is a space separated
  # list of plugins to load.
   mail_plugins = cmusieve
   mail_plugin_dir = /usr/lib/dovecot/lda

  # If user is over quota, return with temporary failure instead of
  # bouncing the mail.
  #quota_full_tempfail = no

  # Format to use for logging mail deliveries. You can use variables:
  #  %$ - Delivery status message (e.g. "saved to INBOX")
  #  %m - Message-ID
  #  %s - Subject
  #  %f - From address
  #deliver_log_format = msgid=%m: %$

  # Binary to use for sending mails.
  #sendmail_path = /usr/lib/sendmail

  # Human readable error message for rejection mails. Use can use variables:
  #  %n = CRLF, %r = reason, %s = subject, %t = recipient
  #rejection_reason = Your message to <%t> was automatically rejected:%n%r

  # UNIX socket path to master authentication server to find users.
  #auth_socket_path = /var/run/dovecot/auth-master
}

main.cf
Rich (BBCode):
# The mailbox_command parameter specifies the optional external
# command to use instead of mailbox delivery. The command is run as
# the recipient with proper HOME, SHELL and LOGNAME environment settings.
# Exception:  delivery for root is done as $default_user.
#
# Other environment variables of interest: USER (recipient username),
# EXTENSION (address extension), DOMAIN (domain part of address),
# and LOCAL (the address localpart).
#
# Unlike other Postfix configuration parameters, the mailbox_command
# parameter is not subjected to $parameter substitutions. This is to
# make it easier to specify shell syntax (see example below).
#
# Avoid shell meta characters because they will force Postfix to run
# an expensive shell process. Procmail alone is expensive enough.
#
# IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN
# ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.
#
mailbox_command = /usr/syno/mailstation/libexec/dovecot/deliver

No errors or stops that I could see during compiling.

Rich (BBCode):
NAS> cd /lib/dovecot/
NAS> ls
lda  lib90_cmusieve_plugin.la
NAS> cd lda
NAS> dir
total 732
drwxr-xr-x 2 root root   4096 May 21 21:50 .
drwxr-xr-x 3 root root   4096 May 21 21:49 ..
-rw-r--r-- 1 root root 417214 May 24 20:45 lib90_cmusieve_plugin.a
-rw-r--r-- 1 root root    909 May 24 20:45 lib90_cmusieve_plugin.la
-rw-r--r-- 1 root root    909 May 24 20:45 lib90_cmusieve_plugin.lai
-rwxr-xr-x 1 root root 303391 May 24 20:45 lib90_cmusieve_plugin.so
NAS>

Rich (BBCode):
NAS> cd /usr/syno/mailstation/libexec/dovecot/
NAS> ls
deliver  dovecot-auth  imap  imap-login  pop3  pop3-login  sievec  sieved  ssl-build-param
NAS>

Rich (BBCode):
NAS> cd /usr/syno/mailstation/libexec/
NAS> ls
anvil   cleanup  dovecot  flush  master  pickup  proxymap  qmqpd   showq  smtpd  tlsmgr           verify
bounce  discard  error    local  oqmgr   pipe    qmgr      scache  smtp   spawn  trivial-rewrite  virtual
NAS>

Thanks
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
Your files and directories look okay. I think that should work. Are you sure that the target directory in the mailbox (.dovecot-sieve) is correct? Did you check that on the command line? Often directories within mailboxes are hidden (that depends from the clientsoftware that created the mailbox)
and did you make the symlink for the config file?
Code:
[FONT=monospace]
[/FONT]ln -s /usr/syno/mailstation/etc/dovecot.conf /usr/local/etc/dovecot.conf
[FONT=monospace]
[/FONT]
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
Your files and directories look okay. I think that should work. Are you sure that the target directory in the mailbox (.dovecot-sieve) is correct? Did you check that on the command line? Often directories within mailboxes are hidden (that depends from the clientsoftware that created the mailbox)
and did you make the symlink for the config file?
Code:
[FONT=monospace]
[/FONT]ln -s /usr/syno/mailstation/etc/dovecot.conf /usr/local/etc/dovecot.conf
[FONT=monospace]
[/FONT]

You mean does "Junk" exist in .Maildir?

I can see it here

Rich (BBCode):
NAS> cd /volume1/homes/UserA/.Maildir/
NAS> dir
total 416
drwx------ 13 UserA users   4096 May 24 21:29 .
drwxr-xr-x  3 UserA users   4096 May 24 20:19 ..
drwx------  5 UserA users   4096 May 23 19:01 .Deleted Messages
drwx------  5 UserA users   4096 Mar  3 19:02 .Drafts
drwx------  5 UserA users   4096 May  9 20:02 .INBOX.Important
drwx------  5 UserA users   4096 May 24 21:08 .Junk
drwx------  5 UserA users   4096 May 24 10:21 .Junk E-mail
drwx------  5 UserA users   4096 May 24 21:03 .Sent Items
drwx------  5 UserA users   4096 May 23 21:02 .Sent Messages
drwx------  5 UserA users   4096 May 24 18:37 .Trash
-rwxr-xr-x  1 root  root     302 May 23 15:31 .dovecot-sieve
drwx------  2 UserA users  20480 May 24 21:29 cur
-rw-------  1 UserA users     24 May 23 13:03 dovecot-keywords
-rw-------  1 UserA users  11441 May 24 21:29 dovecot-uidlist
-rw-------  1 UserA users      8 May 17 23:09 dovecot-uidvalidity
-rw-------  1 UserA users      0 Feb 11 08:56 dovecot-uidvalidity.4d54f9b3
-rw-------  1 UserA users   4336 May 24 21:29 dovecot.index
-rw-------  1 UserA users 280576 May 24 21:29 dovecot.index.cache
-rw-------  1 UserA users  26148 May 24 21:29 dovecot.index.log
drwx------  2 UserA users   4096 May 24 21:29 new
-rw-------  1 UserA users     94 May 17 23:09 subscriptions
drwx------  2 UserA users   4096 May 24 21:29 tmp
NAS>
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
Yes it exists but as .Trash or .Junk
but you wrote in your code
Code:
if header :comparator "i;ascii-casemap" :contains "subject" "*****SPAM*****" { 
fileinto "Trash";   
stop;
but that should be .Trash in your case
My guess is: Everything works fine but you just used a wrong destination for the sieve ;-)
 

Spuddy

Benutzer
Mitglied seit
24. Mai 2011
Beiträge
19
Punkte für Reaktionen
0
Punkte
0
I changed the .dovecot-sieve to .Trash but it still delivers to Inbox :( This is a virtual user by the way, not sure if this makes any difference?

Does anything need restarting after change to .dovecot-sieve or should it take effect immediately?
 

jahlives

Benutzer
Mitglied seit
19. Aug 2008
Beiträge
18.275
Punkte für Reaktionen
4
Punkte
0
ah man I think I got it. The File is called .dovecot.sieve and not .dovecot-sieve. Sorry I did not see that before. Did I write it that way (wrong) in the wiki?
 
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