mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-17 07:33:57 +00:00
feat(alarms): Add possibility to use SMTP master account for system alarms. Fixes #5565.
This commit is contained in:
@@ -3384,7 +3384,8 @@ void handle_eas_terminate(int signum)
|
|||||||
toRecipients: theRecipients
|
toRecipients: theRecipients
|
||||||
sender: from
|
sender: from
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: NO];
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1927,6 +1927,15 @@ To disable TLS verification for localhost domains, add
|
|||||||
Current, only `PLAIN` is supported and other values will cause
|
Current, only `PLAIN` is supported and other values will cause
|
||||||
the authentication to fail.
|
the authentication to fail.
|
||||||
|
|
||||||
|
|D |SOGoSMTPMasterUserEnabled
|
||||||
|
|Enable specific SMTP user account for system e-mails (notifications, reminders, ...). Default is `NO`.
|
||||||
|
|
||||||
|
|D |SOGoSMTPMasterUserUsername
|
||||||
|
|SMTP account username for master account (`SOGoSMTPMasterUserEnabled` enabled).
|
||||||
|
|
||||||
|
|D |SOGoSMTPMasterUserPassword
|
||||||
|
|SMTP account password for master account (`SOGoSMTPMasterUserEnabled` enabled).
|
||||||
|
|
||||||
|S |WOSendMail
|
|S |WOSendMail
|
||||||
|The path of the sendmail binary.
|
|The path of the sendmail binary.
|
||||||
|
|
||||||
|
|||||||
@@ -919,7 +919,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: email]
|
toRecipients: [NSArray arrayWithObject: email]
|
||||||
sender: shortSenderEmail
|
sender: shortSenderEmail
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1022,7 +1023,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: email]
|
toRecipients: [NSArray arrayWithObject: email]
|
||||||
sender: [attendee rfc822Email]
|
sender: [attendee rfc822Email]
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1175,7 +1177,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
||||||
sender: senderEmail
|
sender: senderEmail
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[self container] notifyUserOnPersonalModifications] &&
|
if ([[self container] notifyUserOnPersonalModifications] &&
|
||||||
@@ -1192,7 +1195,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
||||||
sender: senderEmail
|
sender: senderEmail
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
|
|
||||||
[headerMap setObject: o forKey: @"to"];
|
[headerMap setObject: o forKey: @"to"];
|
||||||
}
|
}
|
||||||
@@ -1207,7 +1211,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
toRecipients: [NSArray arrayWithObject: recipientEmail]
|
||||||
sender: senderEmail
|
sender: senderEmail
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2174,7 +2174,8 @@ static NSString *userAgent = nil;
|
|||||||
toRecipients: [NSArray arrayWithObject: recipient]
|
toRecipients: [NSArray arrayWithObject: recipient]
|
||||||
sender: [self sender]
|
sender: [self sender]
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: NO];
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
@@ -2199,7 +2200,8 @@ static NSString *userAgent = nil;
|
|||||||
toRecipients: [self allBareRecipients]
|
toRecipients: [self allBareRecipients]
|
||||||
sender: [self sender]
|
sender: [self sender]
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error && copyToSent)
|
if (!error && copyToSent)
|
||||||
|
|||||||
@@ -953,7 +953,8 @@ static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSDictionary *
|
|||||||
toRecipients: [NSArray arrayWithObject: recipient]
|
toRecipients: [NSArray arrayWithObject: recipient]
|
||||||
sender: [[identities objectAtIndex: 0] objectForKey: @"email"]
|
sender: [[identities objectAtIndex: 0] objectForKey: @"email"]
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: NO];
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -60,7 +60,10 @@
|
|||||||
- (NSString *) vacationFooterTemplateFile;
|
- (NSString *) vacationFooterTemplateFile;
|
||||||
- (NSString *) mailingMechanism;
|
- (NSString *) mailingMechanism;
|
||||||
- (NSString *) smtpServer;
|
- (NSString *) smtpServer;
|
||||||
- (NSString *) smtpAuthenticationType;
|
- (BOOL)smtpMasterUserEnabled;
|
||||||
|
- (NSString *)smtpMasterUserUsername;
|
||||||
|
- (NSString *) smtpMasterUserPassword;
|
||||||
|
- (NSString *)smtpAuthenticationType;
|
||||||
- (NSString *) mailSpoolPath;
|
- (NSString *) mailSpoolPath;
|
||||||
- (float) softQuotaRatio;
|
- (float) softQuotaRatio;
|
||||||
- (BOOL) mailKeepDraftsAfterSend;
|
- (BOOL) mailKeepDraftsAfterSend;
|
||||||
|
|||||||
@@ -292,6 +292,21 @@
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) smtpMasterUserEnabled
|
||||||
|
{
|
||||||
|
return [self boolForKey: @"SOGoSMTPMasterUserEnabled"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) smtpMasterUserUsername
|
||||||
|
{
|
||||||
|
return [self stringForKey: @"SOGoSMTPMasterUserUsername"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) smtpMasterUserPassword
|
||||||
|
{
|
||||||
|
return [self stringForKey: @"SOGoSMTPMasterUserPassword"];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) smtpAuthenticationType
|
- (NSString *) smtpAuthenticationType
|
||||||
{
|
{
|
||||||
return [[self stringForKey: @"SOGoSMTPAuthenticationType"] lowercaseString];
|
return [[self stringForKey: @"SOGoSMTPAuthenticationType"] lowercaseString];
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
{
|
{
|
||||||
NSString *mailingMechanism;
|
NSString *mailingMechanism;
|
||||||
NSString *smtpServer;
|
NSString *smtpServer;
|
||||||
|
BOOL *smtpMasterUserEnabled;
|
||||||
|
NSString *smtpMasterUserUsername;
|
||||||
|
NSString *smtpMasterUserPassword;
|
||||||
NSString *authenticationType;
|
NSString *authenticationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,21 +46,24 @@
|
|||||||
|
|
||||||
- (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd;
|
- (id) initWithDomainDefaults: (SOGoDomainDefaults *) dd;
|
||||||
- (BOOL) requiresAuthentication;
|
- (BOOL) requiresAuthentication;
|
||||||
- (NSException *) sendMailData: (NSData *) data
|
- (NSException *)sendMailData:(NSData *)data
|
||||||
toRecipients: (NSArray *) recipients
|
toRecipients:(NSArray *)recipients
|
||||||
sender: (NSString *) sender
|
sender:(NSString *)sender
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
withAuthenticator:(id<SOGoAuthenticator>)authenticator
|
||||||
inContext: (WOContext *) woContext;
|
inContext:(WOContext *)woContext
|
||||||
- (NSException *) sendMailAtPath: (NSString *) filename
|
systemMessage:(BOOL)isSystemMessage;
|
||||||
toRecipients: (NSArray *) recipients
|
- (NSException *)sendMailAtPath:(NSString *)filename
|
||||||
sender: (NSString *) sender
|
toRecipients:(NSArray *)recipients
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
sender:(NSString *)sender
|
||||||
inContext: (WOContext *) woContext;
|
withAuthenticator:(id<SOGoAuthenticator>)authenticator
|
||||||
- (NSException *) sendMimePart: (id <NGMimePart>) part
|
inContext:(WOContext *)woContext
|
||||||
toRecipients: (NSArray *) recipients
|
systemMessage:(BOOL)isSystemMessage;
|
||||||
sender: (NSString *) sender
|
- (NSException *)sendMimePart:(id<NGMimePart>)part
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
toRecipients:(NSArray *)recipients
|
||||||
inContext: (WOContext *) woContext;
|
sender:(NSString *)sender
|
||||||
|
withAuthenticator:(id<SOGoAuthenticator>)authenticator
|
||||||
|
inContext:(WOContext *)woContext
|
||||||
|
systemMessage:(BOOL)isSystemMessage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,9 @@
|
|||||||
{
|
{
|
||||||
ASSIGN (mailingMechanism, [dd mailingMechanism]);
|
ASSIGN (mailingMechanism, [dd mailingMechanism]);
|
||||||
ASSIGN (smtpServer, [dd smtpServer]);
|
ASSIGN (smtpServer, [dd smtpServer]);
|
||||||
|
smtpMasterUserEnabled = [dd smtpMasterUserEnabled];
|
||||||
|
ASSIGN (smtpMasterUserUsername, [dd smtpMasterUserUsername]);
|
||||||
|
ASSIGN (smtpMasterUserPassword, [dd smtpMasterUserPassword]);
|
||||||
ASSIGN (authenticationType,
|
ASSIGN (authenticationType,
|
||||||
[[dd smtpAuthenticationType] lowercaseString]);
|
[[dd smtpAuthenticationType] lowercaseString]);
|
||||||
}
|
}
|
||||||
@@ -167,6 +170,9 @@
|
|||||||
{
|
{
|
||||||
mailingMechanism = nil;
|
mailingMechanism = nil;
|
||||||
smtpServer = nil;
|
smtpServer = nil;
|
||||||
|
smtpMasterUserEnabled = NO;
|
||||||
|
smtpMasterUserUsername = nil;
|
||||||
|
smtpMasterUserPassword = nil;
|
||||||
authenticationType = nil;
|
authenticationType = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +183,8 @@
|
|||||||
{
|
{
|
||||||
[mailingMechanism release];
|
[mailingMechanism release];
|
||||||
[smtpServer release];
|
[smtpServer release];
|
||||||
|
[smtpMasterUserUsername release];
|
||||||
|
[smtpMasterUserPassword release];
|
||||||
[authenticationType release];
|
[authenticationType release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
@@ -226,6 +234,7 @@
|
|||||||
sender: (NSString *) sender
|
sender: (NSString *) sender
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
||||||
inContext: (WOContext *) woContext
|
inContext: (WOContext *) woContext
|
||||||
|
systemMessage: (BOOL) isSystemMessage
|
||||||
{
|
{
|
||||||
NSString *currentTo, *login, *password;
|
NSString *currentTo, *login, *password;
|
||||||
NSMutableArray *toErrors;
|
NSMutableArray *toErrors;
|
||||||
@@ -254,13 +263,26 @@
|
|||||||
inDomain: [[authenticator userInContext: woContext] domain]];
|
inDomain: [[authenticator userInContext: woContext] domain]];
|
||||||
|
|
||||||
password = [authenticator passwordInContext: woContext];
|
password = [authenticator passwordInContext: woContext];
|
||||||
if ([login length] == 0
|
|
||||||
|
if (isSystemMessage
|
||||||
|
&& ![[[SOGoUserManager sharedUserManager] getEmailForUID: [[authenticator userInContext: woContext] loginInDomain]] isEqualToString: sender]
|
||||||
|
&& smtpMasterUserEnabled) {
|
||||||
|
if (![client plainAuthenticateUser: smtpMasterUserUsername
|
||||||
|
withPassword: smtpMasterUserPassword]) {
|
||||||
|
result = [NSException exceptionWithHTTPStatus: 500
|
||||||
|
reason: @"cannot send message:"
|
||||||
|
@" (smtp) authentication failure"];
|
||||||
|
[self errorWithFormat: @"Could not connect to the SMTP server with master credentials %@", smtpServer];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ([login length] == 0
|
||||||
|| [login isEqualToString: @"anonymous"]
|
|| [login isEqualToString: @"anonymous"]
|
||||||
|| ![client plainAuthenticateUser: login
|
|| ![client plainAuthenticateUser: login
|
||||||
withPassword: password])
|
withPassword: password])
|
||||||
result = [NSException exceptionWithHTTPStatus: 500
|
result = [NSException exceptionWithHTTPStatus: 500
|
||||||
reason: @"cannot send message:"
|
reason: @"cannot send message:"
|
||||||
@" (smtp) authentication failure"];
|
@" (smtp) authentication failure"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (authenticationType && ![authenticator isKindOfClass: [SOGoEmptyAuthenticator class]])
|
else if (authenticationType && ![authenticator isKindOfClass: [SOGoEmptyAuthenticator class]])
|
||||||
result = [NSException
|
result = [NSException
|
||||||
@@ -327,6 +349,7 @@
|
|||||||
sender: (NSString *) sender
|
sender: (NSString *) sender
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
||||||
inContext: (WOContext *) woContext
|
inContext: (WOContext *) woContext
|
||||||
|
systemMessage: (BOOL) isSystemMessage
|
||||||
{
|
{
|
||||||
NSException *result;
|
NSException *result;
|
||||||
|
|
||||||
@@ -399,7 +422,8 @@
|
|||||||
toRecipients: recipients
|
toRecipients: recipients
|
||||||
sender: [sender pureEMailAddress]
|
sender: [sender pureEMailAddress]
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: woContext];
|
inContext: woContext
|
||||||
|
systemMessage: isSystemMessage];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,6 +435,7 @@
|
|||||||
sender: (NSString *) sender
|
sender: (NSString *) sender
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
||||||
inContext: (WOContext *) woContext
|
inContext: (WOContext *) woContext
|
||||||
|
systemMessage: (BOOL) isSystemMessage
|
||||||
{
|
{
|
||||||
NSData *mailData;
|
NSData *mailData;
|
||||||
|
|
||||||
@@ -421,7 +446,8 @@
|
|||||||
toRecipients: recipients
|
toRecipients: recipients
|
||||||
sender: sender
|
sender: sender
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: woContext];
|
inContext: woContext
|
||||||
|
systemMessage: isSystemMessage];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSException *) sendMailAtPath: (NSString *) filename
|
- (NSException *) sendMailAtPath: (NSString *) filename
|
||||||
@@ -429,6 +455,7 @@
|
|||||||
sender: (NSString *) sender
|
sender: (NSString *) sender
|
||||||
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
withAuthenticator: (id <SOGoAuthenticator>) authenticator
|
||||||
inContext: (WOContext *) woContext
|
inContext: (WOContext *) woContext
|
||||||
|
systemMessage: (BOOL) isSystemMessage
|
||||||
{
|
{
|
||||||
NSException *result;
|
NSException *result;
|
||||||
NSData *mailData;
|
NSData *mailData;
|
||||||
@@ -439,7 +466,8 @@
|
|||||||
toRecipients: recipients
|
toRecipients: recipients
|
||||||
sender: sender
|
sender: sender
|
||||||
withAuthenticator: authenticator
|
withAuthenticator: authenticator
|
||||||
inContext: woContext];
|
inContext: woContext
|
||||||
|
systemMessage: isSystemMessage];
|
||||||
else
|
else
|
||||||
result = [NSException exceptionWithHTTPStatus: 500
|
result = [NSException exceptionWithHTTPStatus: 500
|
||||||
reason: @"cannot send message: no data"
|
reason: @"cannot send message: no data"
|
||||||
|
|||||||
@@ -143,7 +143,9 @@
|
|||||||
[mailer sendMimePart: message
|
[mailer sendMimePart: message
|
||||||
toRecipients: [NSArray arrayWithObject: [to objectForKey: @"email"]]
|
toRecipients: [NSArray arrayWithObject: [to objectForKey: @"email"]]
|
||||||
sender: [to objectForKey: @"email"]
|
sender: [to objectForKey: @"email"]
|
||||||
withAuthenticator: staticAuthenticator inContext: nil];
|
withAuthenticator: staticAuthenticator
|
||||||
|
inContext: nil
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _processAlarm: (iCalAlarm *) alarm
|
- (void) _processAlarm: (iCalAlarm *) alarm
|
||||||
|
|||||||
@@ -697,7 +697,8 @@ static NSString *mailETag = nil;
|
|||||||
toRecipients: [NSArray arrayWithObject: email]
|
toRecipients: [NSArray arrayWithObject: email]
|
||||||
sender: [self _matchingIdentityEMail]
|
sender: [self _matchingIdentityEMail]
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context])
|
inContext: context
|
||||||
|
systemMessage: YES])
|
||||||
[self _flagMessageWithMDNSent];
|
[self _flagMessageWithMDNSent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -888,7 +888,8 @@ static const NSString *kJwtKey = @"jwt";
|
|||||||
toRecipients: [NSArray arrayWithObjects: toEmail, nil]
|
toRecipients: [NSArray arrayWithObjects: toEmail, nil]
|
||||||
sender: fromEmail
|
sender: fromEmail
|
||||||
withAuthenticator: [SOGoEmptyAuthenticator sharedSOGoEmptyAuthenticator]
|
withAuthenticator: [SOGoEmptyAuthenticator sharedSOGoEmptyAuthenticator]
|
||||||
inContext: [self context]];
|
inContext: [self context]
|
||||||
|
systemMessage: YES];
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
response = [self responseWithStatus: 200
|
response = [self responseWithStatus: 200
|
||||||
|
|||||||
@@ -238,7 +238,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: recipient]
|
toRecipients: [NSArray arrayWithObject: recipient]
|
||||||
sender: from
|
sender: from
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -208,7 +208,8 @@
|
|||||||
toRecipients: [NSArray arrayWithObject: recipient]
|
toRecipients: [NSArray arrayWithObject: recipient]
|
||||||
sender: from
|
sender: from
|
||||||
withAuthenticator: [self authenticatorInContext: context]
|
withAuthenticator: [self authenticatorInContext: context]
|
||||||
inContext: context];
|
inContext: context
|
||||||
|
systemMessage: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user