Problem to catchall mails with "Always send a copy (BCC)" on NethServer 7.3

mailserver
mail
v7

(Mario Matyssek) #1

NethServer Version: 7.3
Module: Email

Hi folks,
I have a standard installation of 2 versions: NethServer 6.9 and NethServer 7.3. These servers are used as local mailserver (intranet). Smarthost is used to send/ receive mails to/ from ISP’s mail server…
I have checked the box in Email-> Messages “Always send a copy (BCC)”. This works at NethServer 6.9 but doesn’t work with version 7.3. If I send a mail this will be CCed to mailcc@FQDN (my catchall mailbox/ user) and everything is fine. But if I send a mail to an external echo mailserver (via ISP’s mail server) the reply (echo mail) will be sent only to the senders postbox and not to the mailcc-Postbox.
Maybe this depends on Email alias domains or server alias? Is the character “-” (minus) allowed for domain names? My server name is “mail.proxyserver.de”. Additional I have set “company-place.de” as an alias.
Next I will try to proceed with an update process vom NethServer 6.9 to 7.3…
What can I do else for debug/ diagnostic or does anybody have an idea to check this behaviour?

Best regards,
Mario!


(Alessio Fattorini) #2

Uhm, it looks weird. We should replicate this behaviour.


(Mario Matyssek) #3

I still don’t have a solution for this. Let me describe some details…
I have a fresh install of NethServer 7.3.:

Now I can send mails from “banane” to “kiwi” and I will get a copy to “mailcc”. So far so good.
Next I want to send mails to an external mailbox via an ISP mailserver. What do I have to do?
I have to configure:

  1. a second Email Domain “xxx-erfurt.de” on NethServer according to the public mailbox domain
  2. Smarthost function with correct data for sending mails to the ISP
  3. POP3 connector with external mail account data to get mails from the ISP to NethServer
    Is this right?

Now I send a mail from "banane@xxx-erfurt.de" to an echomail Server (echo@tu-chemnitz.de).
What happens: I get a copy of this mail I’ve send to the "mailcc@proxyserver.de". After a minute or two the echomail comes from the echomail server to "banane@xxx-erfurt.de". That’s right but I also expect to receive a copy to "mailcc@proxyserver.de". But I have never seen such a mail… :confused:

Please can anyone give me an advice? Can you replicate this behaviour?
Don’t hesitate to contact me!
Thanks for spending your time and best regards,
Mario!


(Filippo Carletti) #4

From memory: mail downloaded using the POP3 connector doesn’t respect the Bcc settings.
Workaround: a sieve filter.


(Mario Matyssek) #5

Oh, many thanks for this advice!
How can I do this? I’ve no experience with this…
With kind regards
Mario


(Mario Matyssek) #6

…for test purposes I’ve put these lines into "/var/lib/nethserver/sieve-scripts/before-sieve/“
require [“copy”];
if true
{
redirect: copy "mailcc@proxyserver.de”;
}
:slight_smile:


(Filippo Carletti) #7

That’s it, great job.
EDIT: if it works, you should “fix” the configuration using a template-custom.


(Mario Matyssek) #8

Hi all,
I think I’ve done 1 step to the solution…
The sieve filter now makes a copy to "mailcc@proxyserver.de" but I get 4 duplicate messages from the echo mailserver to mailcc. How can I prevent this?


(Filippo Carletti) #9

No idea, sorry. Are the 4 messages the same? Look at the headers, please.


(Mario Matyssek) #10

Hi all,
with these settings for sieve filter I’ve got still 2 mail copies to mailcc@proxyserver.de. The originating mail was sent from "banane@ifam-erfurt.de" to "echo@tu-chemnitz.de"- I will get an echo mail from "echo@tu-chemnitz.de" to "banane@ifam-erfurt.de". This works well.
[“ifam-erfurt.de” is a 2nd Email domain name for “proxyserver.de”]

before.sieve:

Mailheader:

NethServer /var/log/maillog

Is there anything else I could do better to prevent duplicate mails?


(Mario Matyssek) #11

Hmm, I’ve unchecked Email-> Messages-> Always send a copy (Bcc)… and now I will receive only 1 message as a copy from "echo@tu-chemnitz.de" to "mailcc@proxyserver.de" (and of course to "banane@ifam-erfurt.de"). This is exactly the behaviour I would like to see. :slight_smile:

Unfortunately in this case I won’t receive a copy of the mail I have sent from “banane” to the echo Server…


(Filippo Carletti) #12

Could you add a line containing
stop;
after redirect (as in the spam rule above).


(Mario Matyssek) #13

Hi Filipo,
I have added the line with
stop;
from your advice, but the result is the same, no change at all (2 duplicate mails). :confused:
I am totally confused because I receive additional mails to ‘mailcc’ from sending “banane” -> “echo” after I had used the sieve filter…?
Does sieve filter work for outgoing and incoming mails?
Mario


(Mario Matyssek) #14

I’ve seen there are some extensions for the sieve package, one of them is called ‘duplicate extension’. Whats about this, can I install/ use this extension? How can I install an extension?


(Filippo Carletti) #15

Incoming only.
I have a customization to disable delivery of duplicated email.
It’s a small .tar.gz file I could send to your email address (if you can give it to me in a Private Message).


(Mario Matyssek) #16

Hi all,

it is great- now it works!! :smiley::thumbsup:

I am very satisfied with the help of your support, my problem is solved and everything works very well. The duplicate extension for Sieve filters does the job. A big compliment and many thanks for the great support!

Summary:
I wanted to use the Option “Configuration: Email-> Messages-> Always send a copy (Bcc)…” This already works for outgoing mails (postfix will do this, right?). For incoming mails you have to add a line with 'redirect: copy "<catchall-mailbox>";' into “/var/lib/nethserver/sieve-scripts/before-sieve/”.
And then it is usefull to install/ use the ‘Duplicate extension’ for Sieve filters to avoid duplicate mails.

The only thing I have to do is to create a custom template for sieve…

Finally I am very pleased to found NethServer Project and this community.

Best regards
Mario!


(Luca Aguzzoli) #17

hello everyone, can i ask the exact syntax of the file? I do not function and I get this error:


Sep 13 13:40:02 mail dovecot: lda (assistenza@xxxxx.it): Error: sieve: before: line 21: expected end of command ‘;’ or the beginning of a compound block ‘{’, but found ':'
Sep 13 13:40:02 mail dovecot: lda (assistenza@xxxxx.it): Error: sieve: before: parse failed
Sep 13 13:40:02 mail dovecot: lda (assistenza@xxxxx.it): Error: failed to compile script /var/lib/nethserver/sieve-scripts/before.sieve


The sys file is configured as follows:

#
# 10junkmail
#
# - enabled (move marked SPAM messages into junkmail folder)
require ["fileinto", "mailbox"];
if header: contains "X-Spam-Flag" "YES" {
    file: create "Junk";
     stop;
}
else

redirect: copy "nuovoarchivio@xxxxxxxx.it";
    stop;

Thank you all!
Luca


(Mario Matyssek) #18

Hi luca, please try this one:

#
# 10junkmail
#
# - enabled (move marked SPAM messages into junkmail folder)
require ["fileinto", "mailbox", "copy"];
if header: contains "X-Spam-Flag" "YES" {
    file: create "Junk";
     stop;
}
else
{
    redirect: copy "nuovoarchivio@xxxxxxxx.it";
    stop;
}

You should insert the keyword “copy” and some brackets…
Regards Mario


(Luca Aguzzoli) #19

Hi Mario,
now i’ve got this error:

Error: sieve: before: line 21: expected end of command ‘;’ or the beginning of a compound block ‘{’, but found ':'
Sep 13 14:20:02 posta dovecot: lda(assistenza@xxxxx.it): Error: sieve: before: parse failed
Sep 13 14:20:02 posta dovecot: lda(assistenza@xxxxx.it): Error: sieve: failed to compile script /var/lib/nethserver/sieve-scripts/before.sieve

Line 21 is :
redirect: copy "nuovoarchivio@xxxxxxxx.it";


(Mario Matyssek) #20

Hi luca,
in my first attempts to edit this sieve script I made the same mistake…
It is important that you type the semicolon without space after but with a space before! :slight_smile:
… “header :contains”
… “file :create”
… “redirect :copy”…
Sure this will help you
Mario