diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m
index d120120ea..7d1859ab4 100644
--- a/SoObjects/Mailer/SOGoDraftObject.m
+++ b/SoObjects/Mailer/SOGoDraftObject.m
@@ -2280,9 +2280,11 @@ static NSString *userAgent = nil;
SOGoDomainDefaults *dd;
NSURL *sourceIMAP4URL, *smtpUrl;
NSException *error;
+ NSString *userId;
dd = [[context activeUser] domainDefaults];
messageForSent = nil;
+ userId = [[self->container mailAccountFolder] nameInContainer];
// If we are encrypting mails, let's generate and
// send them individually
@@ -2311,7 +2313,7 @@ static NSString *userAgent = nil;
if (smtpUrl)
{
- error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl]
+ error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl userIdAccount: userId]
sendMailData: message
toRecipients: [NSArray arrayWithObject: recipient]
sender: [self sender]
@@ -2352,13 +2354,26 @@ static NSString *userAgent = nil;
smtpUrl = [self smtp4URL];
- error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl]
- sendMailData: message
- toRecipients: [self allBareRecipients]
- sender: [self sender]
+ if (smtpUrl)
+ {
+ error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl userIdAccount: userId]
+ sendMailData: message
+ toRecipients: [self allBareRecipients]
+ sender: [self sender]
withAuthenticator: [self authenticatorInContext: context]
- inContext: context
- systemMessage: NO];
+ inContext: context
+ systemMessage: NO];
+ }
+ else
+ {
+ error = [[SOGoMailer mailerWithDomainDefaults: dd]
+ sendMailData: message
+ toRecipients: [self allBareRecipients]
+ sender: [self sender]
+ withAuthenticator: [self authenticatorInContext: context]
+ inContext: context
+ systemMessage: NO];
+ }
}
if (!error && copyToSent)
diff --git a/SoObjects/SOGo/SOGoMailer.h b/SoObjects/SOGo/SOGoMailer.h
index 73934e8da..174df3596 100644
--- a/SoObjects/SOGo/SOGoMailer.h
+++ b/SoObjects/SOGo/SOGoMailer.h
@@ -40,11 +40,14 @@
NSString *smtpMasterUserUsername;
NSString *smtpMasterUserPassword;
NSString *authenticationType;
+ NSString* userIdAccount;
}
+ (SOGoMailer *) mailerWithDomainDefaults: (SOGoDomainDefaults *) dd;
+ (SOGoMailer *) mailerWithDomainDefaultsAndSmtpUrl: (SOGoDomainDefaults *) dd
- smtpUrl: (NSURL *) smtpUrl;
+ smtpUrl: (NSURL *) smtpUrl
+ userIdAccount: (NSString *) userIdAccount;
+
- (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd;
- (BOOL) requiresAuthentication;
diff --git a/SoObjects/SOGo/SOGoMailer.m b/SoObjects/SOGo/SOGoMailer.m
index 94c154758..9f302da5f 100644
--- a/SoObjects/SOGo/SOGoMailer.m
+++ b/SoObjects/SOGo/SOGoMailer.m
@@ -150,9 +150,11 @@
+ (SOGoMailer *) mailerWithDomainDefaultsAndSmtpUrl: (SOGoDomainDefaults *) dd
smtpUrl: (NSURL *) smtpUrl
+ userIdAccount: (NSString *) _userIdAccount
{
return [[self alloc] initWithDomainDefaultsAndSmtpUrl: dd
- smtpUrl: smtpUrl];
+ smtpUrl: smtpUrl
+ userIdAccount: _userIdAccount];
}
- (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd
@@ -165,6 +167,7 @@
ASSIGN (smtpMasterUserUsername, [dd smtpMasterUserUsername]);
ASSIGN (smtpMasterUserPassword, [dd smtpMasterUserPassword]);
ASSIGN (authenticationType, [[dd smtpAuthenticationType] lowercaseString]);
+ ASSIGN (userIdAccount, @"0");
}
return self;
@@ -172,6 +175,7 @@
- (id) initWithDomainDefaultsAndSmtpUrl: (SOGoDomainDefaults *) dd
smtpUrl: (NSURL *) smtpUrl
+ userIdAccount: (NSString *) _userIdAccount
{
if ((self = [self init]))
{
@@ -181,6 +185,7 @@
ASSIGN (smtpMasterUserUsername, [dd smtpMasterUserUsername]);
ASSIGN (smtpMasterUserPassword, [dd smtpMasterUserPassword]);
ASSIGN (authenticationType, [[dd smtpAuthenticationType] lowercaseString]);
+ ASSIGN (userIdAccount, _userIdAccount);
}
return self;
@@ -196,6 +201,7 @@
smtpMasterUserUsername = nil;
smtpMasterUserPassword = nil;
authenticationType = nil;
+ userIdAccount = nil;
}
return self;
@@ -208,6 +214,7 @@
[smtpMasterUserUsername release];
[smtpMasterUserPassword release];
[authenticationType release];
+ [userIdAccount release];
[super dealloc];
}
@@ -259,35 +266,58 @@
systemMessage: (BOOL) isSystemMessage
{
NSString *currentTo, *login, *password;
+ NSDictionary *currentAcount;
NSMutableArray *toErrors;
NSEnumerator *addresses;
NGSmtpClient *client;
NSException *result;
NSURL * smtpUrl;
SOGoUser* user;
+ BOOL doSmtpAuth;
result = nil;
+ doSmtpAuth = NO;
//find the smtpurl for the account
-
smtpUrl = [[[NSURL alloc] initWithString: smtpServer] autorelease];
-
client = [NGSmtpClient clientWithURL: smtpUrl];
+ //Get the user and the current account
+ int userId = [userIdAccount intValue];
+ user = [SOGoUser userWithLogin: [[woContext activeUser] login]];
+ currentAcount = [[user mailAccounts] objectAtIndex: userId];
+
+ //Check if we do an smtp authentication
+ doSmtpAuth = [authenticationType isEqualToString: @"plain"] && ![authenticator isKindOfClass: [SOGoEmptyAuthenticator class]];
+ if(!doSmtpAuth && userId > 0)
+ {
+ doSmtpAuth = [currentAcount objectForKey: @"smtpAuth"] ? [[currentAcount objectForKey: @"smtpAuth"] boolValue] : NO;
+ }
+
NS_DURING
{
[client connect];
- if ([authenticationType isEqualToString: @"plain"] && ![authenticator isKindOfClass: [SOGoEmptyAuthenticator class]])
+ if (doSmtpAuth)
{
- /* XXX Allow static credentials by peeking at the classname */
- if ([authenticator isKindOfClass: [SOGoStaticAuthenticator class]])
- login = [(SOGoStaticAuthenticator *)authenticator username];
+ //Check if the ccurent mail folder if for an auxiliary account (userId > 0)
+ if(userId > 0)
+ {
+ login = [currentAcount objectForKey: @"userName"];
+ password = [currentAcount objectForKey: @"password"];
+ }
else
- login = [[SOGoUserManager sharedUserManager]
- getExternalLoginForUID: [[authenticator userInContext: woContext] loginInDomain]
- inDomain: [[authenticator userInContext: woContext] domain]];
+ {
+ /* XXX Allow static credentials by peeking at the classname */
+ if ([authenticator isKindOfClass: [SOGoStaticAuthenticator class]])
+ login = [(SOGoStaticAuthenticator *)authenticator username];
+ else
+ login = [[SOGoUserManager sharedUserManager]
+ getExternalLoginForUID: [[authenticator userInContext: woContext] loginInDomain]
+ inDomain: [[authenticator userInContext: woContext] domain]];
+
+ password = [authenticator passwordInContext: woContext];
+ }
- password = [authenticator passwordInContext: woContext];
if (isSystemMessage
&& ![[[SOGoUserManager sharedUserManager] getEmailForUID: [[authenticator userInContext: woContext] loginInDomain]] isEqualToString: sender]
@@ -299,7 +329,9 @@
@" (smtp) authentication failure"];
[self errorWithFormat: @"Could not connect to the SMTP server with master credentials %@", smtpServer];
}
- } else {
+ }
+ else
+ {
if ([login length] == 0
|| [login isEqualToString: @"anonymous"]
|| ![client plainAuthenticateUser: login
diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings
index 7d3abe4ba..f21a8dd21 100644
--- a/UI/PreferencesUI/English.lproj/Localizable.strings
+++ b/UI/PreferencesUI/English.lproj/Localizable.strings
@@ -232,6 +232,7 @@
"New Mail Account" = "New Mail Account";
"Server Name" = "Server Name";
"Outgoing Server Name (SMTP)" = "Outgoing Server Name (SMTP)";
+"Smtp Auth" = "Smtp Auth";
"Port" = "Port";
"Encryption" = "Encryption";
"Outgoing Encryption" = "Outgoing Encryption";
diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings
index 14b4d5d45..9c05a8000 100644
--- a/UI/PreferencesUI/French.lproj/Localizable.strings
+++ b/UI/PreferencesUI/French.lproj/Localizable.strings
@@ -232,6 +232,7 @@
"New Mail Account" = "Nouveau compte";
"Server Name" = "Serveur";
"Outgoing Server Name (SMTP)" = "Serveur sortant (SMTP)";
+"Smtp Auth" = "Smtp Auth";
"Port" = "Port";
"Encryption" = "Chiffrement";
"Outgoing Encryption" = "Chiffrement sortant";
diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m
index 1ee89fcee..9eca0cdf1 100644
--- a/UI/PreferencesUI/UIxJSONPreferences.m
+++ b/UI/PreferencesUI/UIxJSONPreferences.m
@@ -513,37 +513,6 @@ static SoProduct *preferencesProduct = nil;
}
[auxAccount setObject: limitedSecurity forKey: @"security"];
}
-
- //Decrypt password if needed
- sogoSecret = [[SOGoSystemDefaults sharedSystemDefaults] sogoSecretValue];
- if (sogoSecret)
- {
- if(![[auxAccount objectForKey: @"password"] isKindOfClass: [NSDictionary class]])
- {
- [self errorWithFormat:@"Can't decrypt the password for auxiliary account %@, is not a dictionnary",
- [auxAccount objectForKey: @"name"]];
- continue;
- }
- accountPassword = [auxAccount objectForKey: @"password"];
- encryptedPassword = [accountPassword objectForKey: @"cypher"];
- iv = [accountPassword objectForKey: @"iv"];
- tag = [accountPassword objectForKey: @"tag"];
- if([encryptedPassword length] > 0)
- {
- NS_DURING
- password = [encryptedPassword decryptAES256GCM: sogoSecret iv: iv tag: tag exception:&exception];
- NS_HANDLER
- [self errorWithFormat:@"Can't decrypt the password for auxiliary account %@, probably not encrypted.",
- [auxAccount objectForKey: @"name"]];
- password = [auxAccount objectForKey: @"password"];
- NS_ENDHANDLER
- if(exception)
- [self errorWithFormat:@"Can't decrypt the password for auxiliary account %@: %@",
- [auxAccount objectForKey: @"name"], [exception reason]];
- else
- [auxAccount setObject: password forKey: @"password"];
- }
- }
}
}
// We inject our default mail account
diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m
index 03bbdedbe..0011fdf84 100644
--- a/UI/PreferencesUI/UIxPreferences.m
+++ b/UI/PreferencesUI/UIxPreferences.m
@@ -1359,7 +1359,7 @@ static NSArray *reminderValues = nil;
if (!knownKeys)
{
knownKeys = [NSArray arrayWithObjects: @"id", @"name", @"serverName", @"port",
- @"smtpServerName", @"smtpPort", @"smtpEncryption",
+ @"smtpServerName", @"smtpPort", @"smtpEncryption", @"smtpAuth",
@"userName", @"password", @"encryption", @"replyTo",
@"identities", @"mailboxes", @"forceDefaultIdentity",
@"receipts", @"security", @"isNew",
diff --git a/UI/Templates/PreferencesUI/UIxAccountEditor.wox b/UI/Templates/PreferencesUI/UIxAccountEditor.wox
index f35388784..974c1b4b6 100644
--- a/UI/Templates/PreferencesUI/UIxAccountEditor.wox
+++ b/UI/Templates/PreferencesUI/UIxAccountEditor.wox
@@ -97,6 +97,14 @@
placeholder=""
sg-placeholder="$AccountDialogController.smtpDefaultPort"/>
+
+
+
+
diff --git a/UI/WebServerResources/scss/components/checkbox/checkbox.scss b/UI/WebServerResources/scss/components/checkbox/checkbox.scss
index c6294b8d0..b697635e4 100644
--- a/UI/WebServerResources/scss/components/checkbox/checkbox.scss
+++ b/UI/WebServerResources/scss/components/checkbox/checkbox.scss
@@ -19,6 +19,12 @@ md-sidenav .md-dense :not(.md-dense-disabled) md-checkbox:not(.md-dense-disabled
min-height: $checkbox-width;
}
+//Checkbox with input container
+md-checkbox.sg-checkbox--input-container {
+ margin: auto;
+ margin-left: 16px;
+}
+
// Checkbox in an inline form beside a select element
.md-inline-form md-checkbox.sg-checkbox--with-select {
margin: 2.5*$baseline-grid $baseline-grid*0.5 3*$baseline-grid + 2 0;