diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 475d19017..f209764e5 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2118,6 +2118,15 @@ automatically forwarding mails. When set to `0` (default), no constraint is enforced. When set to `1`, only internal domains can be used. When set to `2`, only external domains can be used. +|D |SOGoForwardConstraintsDomains +|Parameter used to set which domains are allowed as external domains +when SOGoForwardConstraints is set to `2`. For example, setting: + +SOGoForwardConstraintsDomains = ("gmail.com", "googlemail.com"); + +will allow users to forward emails to only `gmail.com` and `googlemail.com` domains. +When empty or undefined, no constraints are imposed. + |D |SOGoSieveScriptsEnabled |Parameter used to activate the edition from the preferences windows of server-side mail filters. Requires Sieve script support on the IMAP diff --git a/NEWS b/NEWS index ab4505a0a..a2ea31925 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ New features - [core] Debian 10 (Buster) support for x86_64 (#4775) + - [core] now possible to specify which domains you can forward your mails to Enhancements - [web] avoid saving an empty calendar name diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index d64130dfa..3d7d61139 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -1,6 +1,6 @@ /* SOGoDomainDefaults.h - this file is part of SOGo * - * Copyright (C) 2009-2016 Inverse inc. + * Copyright (C) 2009-2019 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,6 +51,7 @@ - (BOOL) sieveScriptsEnabled; - (BOOL) forwardEnabled; - (int) forwardConstraints; +- (NSArray *) forwardConstraintsDomains; - (BOOL) vacationEnabled; - (NSString *) vacationDefaultSubject; - (NSString *) vacationHeaderTemplateFile; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 6f49d0b81..0051dfba3 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -1,6 +1,6 @@ /* SOGoDomainDefaults.m - this file is part of SOGo * - * Copyright (C) 2009-2016 Inverse inc. + * Copyright (C) 2009-2019 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -215,6 +215,11 @@ return (v > 2 ? 0 : v); } +- (NSArray *) forwardConstraintsDomains +{ + return [self stringArrayForKey: @"SOGoForwardConstraintsDomains"]; +} + - (BOOL) vacationEnabled { return [self boolForKey: @"SOGoVacationEnabled"]; diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index 56019e7dd..464db0b46 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -63,6 +63,7 @@ = "Please specify an address to which you want to forward your messages."; "You are not allowed to forward your messages to an external email address." = "You are not allowed to forward your messages to an external email address."; "You are not allowed to forward your messages to an internal email address." = "You are not allowed to forward your messages to an internal email address."; +"You are not allowed to forward your messages to this domain:" = "You are not allowed to forward your messages to this domain:"; /* d & t */ "Current Time Zone" = "Current Time Zone"; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 0994c0a90..6a79469a3 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -1,6 +1,6 @@ /* UIxPreferences.m - this file is part of SOGo * - * Copyright (C) 2007-2018 Inverse inc. + * Copyright (C) 2007-2019 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1495,6 +1495,18 @@ static NSArray *reminderValues = nil; return [NSString stringWithFormat: @"%d", [dd forwardConstraints]]; } +- (NSString *) forwardConstraintsDomains +{ + NSMutableArray *domains; + SOGoDomainDefaults *dd; + + dd = [[context activeUser] domainDefaults]; + domains = [NSMutableArray array]; + [domains addObjectsFromArray: [dd forwardConstraintsDomains]]; + + return [domains jsonRepresentation]; +} + // // Used by templates // diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index db4e53927..eb7d74e2c 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -21,6 +21,7 @@ var defaultEmailAddresses = ''; var defaultCalendarCategories = ; var forwardConstraints = ; + var forwardConstraintsDomains = ; var sieveCapabilities = ; diff --git a/UI/WebServerResources/js/Preferences/PreferencesController.js b/UI/WebServerResources/js/Preferences/PreferencesController.js index 135075b00..73bd081b1 100644 --- a/UI/WebServerResources/js/Preferences/PreferencesController.js +++ b/UI/WebServerResources/js/Preferences/PreferencesController.js @@ -347,6 +347,12 @@ Dialog.alert(l('Error'), l("You are not allowed to forward your messages to an internal email address.")); sendForm = false; } + else if ($window.forwardConstraints == 2 && + $window.forwardConstraintsDomains.length > 0 && + $window.forwardConstraintsDomains.indexOf(domain) < 0) { + Dialog.alert(l('Error'), l("You are not allowed to forward your messages to this domain:") + " " + domain); + sendForm = false; + } } }