So I created three user groups, and added myself to all three of them, then sent an email to all three groups. I received 3 copies of the email. Correct me if I’m wrong, but my assumption is that this configuration should make it so I only receive 1 copy.
As explained in the above link, from dovecot 2.2.18 the duplicate plugin is named just “duplicate” (instead of vnd.dovecot.duplicate) and available by default so the custom template /etc/e-smith/templates-custom/etc/dovecot/dovecot.conf/60lmtp is not needed anymore.
So creating the file /var/lib/nethserver/sieve-scripts/after.sieve with following content should be enough.
# do not deliver duplicate mails
require "duplicate";
if duplicate {
discard;
stop;
}
To be sure restart the mailserver services (maybe not necessary):
signal-event nethserver-mail-server-update
Now mails to groups with same members are delivered only once. I tested with Roundcube and Thunderbird.
I tested it on another server, no reboot or service restart needed. After creating /var/lib/nethserver/sieve-scripts/after.sieve it just worked.
For testing I created 2 groups group1 and group2 and user markus is member of those groups.
I sent a testmail from an external mail account to group1, group2 and markus and markus gets 1 mail.
In /var/log/maillog I can see 1 mail stored in the inbox but the next 2 are discarded:
Sep 28 21:25:57 nethserver dovecot: lmtp(markus@mrmarkuz.org): IADPM0VsU2HsRwAAGa89gA: sieve: msgid=<0909d95b-0ed0-f24e-bf83-cfdc67a2811b@domain.at>: stored mail into mailbox 'INBOX'
Sep 28 21:25:57 nethserver postfix/lmtp[18411]: 10B425C05A9: to=<markus@mrmarkuz.org>, relay=nethserver.mrmarkuz.org[/var/run/dovecot/lmtp], delay=0.92, delays=0.83/0.01/0.02/0.06, dsn=2.0.0, status=sent (250 2.0.0 <markus@mrmarkuz.org> IADPM0VsU2HsRwAAGa89gA Saved)
Sep 28 21:25:57 nethserver dovecot: lmtp(markus@mrmarkuz.org): IADPM0VsU2HsRwAAGa89gA:2: sieve: msgid=<0909d95b-0ed0-f24e-bf83-cfdc67a2811b@domain.at>: marked message to be discarded if not explicitly delivered (discard action)
Sep 28 21:25:57 nethserver postfix/lmtp[18411]: 10B425C05A9: to=<markus@mrmarkuz.org>, orig_to=<devs@mrmarkuz.org>, relay=nethserver.mrmarkuz.org[/var/run/dovecot/lmtp], delay=0.93, delays=0.83/0.01/0.02/0.06, dsn=2.0.0, status=sent (250 2.0.0 <markus@mrmarkuz.org> IADPM0VsU2HsRwAAGa89gA:2 Saved)
Sep 28 21:25:57 nethserver dovecot: lmtp(markus@mrmarkuz.org): IADPM0VsU2HsRwAAGa89gA:3: sieve: msgid=<0909d95b-0ed0-f24e-bf83-cfdc67a2811b@domain.at>: marked message to be discarded if not explicitly delivered (discard action)
Strangely enough, it appears to be working if it’s an external email address, but not an internal address sending to internal groups. Which defeats the purpose, as about 90% of all emails are internally to the groups.
Our active directory domain name is ad.domain.com, and our email domain is domain.com, where domain.com is our actual public domain name, but we don’t use any type of .local or .lan domain name for emails.
Nethserver is not our gateway for the LAN, as it sits behind a Ubiquiti USG-3, but it does have it’s own public IP address (it has two NIC, one internal LAN, and one WAN NIC), so I guess you’d call that Gateway mode.
can confirm it’s working on my system both external and internal
do you have anything else in /etc/e-smith/templates-custom/etc/dovecot/dovecot.conf/ apart from
40namespaces maybey you acciedentaly saved a misspelled 60lmtp
ie /etc/e-smith/templates-custom/etc/dovecot/dovecot.conf/6lmtp
Just for giggles, I did a search for files containing the word ‘duplicate’, in the e-smith folder and it’s sub-directories, and the search turned up no additional files with a similar line or filtering in there.
[01:14] [network ~] # grep -rnw '/etc/e-smith/' -e 'duplicate'
/etc/e-smith/events/actions/nethserver-samba-ns6sidfix:29:# Fix duplicate SID for local machine and domain (required for ns6 upgraded systems)
/etc/e-smith/templates/etc/shorewall/policy/20policy:24: $zones{$zone} = ''; # avoid duplicate policies
/etc/e-smith/templates/etc/rspamd/rspamd.conf/30Logging:8: .include(try=true; priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/logging.inc"
/etc/e-smith/templates/etc/pulledpork/pulledpork.conf/20options:103:# de-dupe any duplicate IPs from different sources.
[01:14] [network ~] #