mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-16 04:13:17 +00:00
feat(accounts): Can now add smtp server to auxilliary accounts
This commit is contained in:
@@ -2278,7 +2278,7 @@ static NSString *userAgent = nil;
|
||||
NSData *message, *messageForSent;
|
||||
SOGoMailFolder *sentFolder;
|
||||
SOGoDomainDefaults *dd;
|
||||
NSURL *sourceIMAP4URL;
|
||||
NSURL *sourceIMAP4URL, *smtpUrl;
|
||||
NSException *error;
|
||||
|
||||
dd = [[context activeUser] domainDefaults];
|
||||
@@ -2307,13 +2307,28 @@ static NSString *userAgent = nil;
|
||||
return [NSException exceptionWithHTTPStatus: 500
|
||||
reason: @"could not generate message content"];
|
||||
|
||||
error = [[SOGoMailer mailerWithDomainDefaults: dd]
|
||||
sendMailData: message
|
||||
toRecipients: [NSArray arrayWithObject: recipient]
|
||||
sender: [self sender]
|
||||
withAuthenticator: [self authenticatorInContext: context]
|
||||
inContext: context
|
||||
systemMessage: NO];
|
||||
smtpUrl = [self smtp4URL];
|
||||
|
||||
if (smtpUrl)
|
||||
{
|
||||
error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl]
|
||||
sendMailData: message
|
||||
toRecipients: [NSArray arrayWithObject: recipient]
|
||||
sender: [self sender]
|
||||
withAuthenticator: [self authenticatorInContext: context]
|
||||
inContext: context
|
||||
systemMessage: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
error = [[SOGoMailer mailerWithDomainDefaults: dd]
|
||||
sendMailData: message
|
||||
toRecipients: [NSArray arrayWithObject: recipient]
|
||||
sender: [self sender]
|
||||
withAuthenticator: [self authenticatorInContext: context]
|
||||
inContext: context
|
||||
systemMessage: NO];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
[self cleanTmpFiles];
|
||||
@@ -2335,7 +2350,9 @@ static NSString *userAgent = nil;
|
||||
return [NSException exceptionWithHTTPStatus: 500
|
||||
reason: @"could not generate message content"];
|
||||
|
||||
error = [[SOGoMailer mailerWithDomainDefaults: dd]
|
||||
smtpUrl = [self smtp4URL];
|
||||
|
||||
error = [[SOGoMailer mailerWithDomainDefaultsAndSmtpUrl: dd smtpUrl: smtpUrl]
|
||||
sendMailData: message
|
||||
toRecipients: [self allBareRecipients]
|
||||
sender: [self sender]
|
||||
|
||||
@@ -95,7 +95,10 @@ typedef enum {
|
||||
- (NSDictionary *) identityForEmail: (NSString *) email;
|
||||
- (NSString *) signature;
|
||||
- (NSString *) encryption;
|
||||
- (NSString *) smtpEncryption;
|
||||
- (NSString *) tlsVerifyMode;
|
||||
- (NSString *) smtpTlsVerifyMode;
|
||||
- (NSMutableString *) smtp4URLString;
|
||||
|
||||
/* folder pathes */
|
||||
- (NSArray *) toManyRelationshipKeysWithNamespaces: (BOOL) withNSs;
|
||||
|
||||
@@ -800,6 +800,17 @@ static NSString *inboxFolderName = @"INBOX";
|
||||
return encryption;
|
||||
}
|
||||
|
||||
- (NSString *) smtpEncryption
|
||||
{
|
||||
NSString *encryption;
|
||||
|
||||
encryption = [[self _mailAccount] objectForKey: @"smtpEncryption"];
|
||||
if (![encryption length])
|
||||
encryption = @"none";
|
||||
|
||||
return encryption;
|
||||
}
|
||||
|
||||
- (NSString *) tlsVerifyMode
|
||||
{
|
||||
NSString *verifyMode;
|
||||
@@ -811,6 +822,17 @@ static NSString *inboxFolderName = @"INBOX";
|
||||
return verifyMode;
|
||||
}
|
||||
|
||||
- (NSString *) smtpTlsVerifyMode
|
||||
{
|
||||
NSString *verifyMode;
|
||||
|
||||
verifyMode = [[self _mailAccount] objectForKey: @"smtpTlsVerifyMode"];
|
||||
if (!verifyMode || ![verifyMode length])
|
||||
verifyMode = @"default";
|
||||
|
||||
return verifyMode;
|
||||
}
|
||||
|
||||
- (NSMutableString *) imap4URLString
|
||||
{
|
||||
NSMutableString *imap4URLString;
|
||||
@@ -849,6 +871,42 @@ static NSString *inboxFolderName = @"INBOX";
|
||||
return imap4URLString;
|
||||
}
|
||||
|
||||
- (NSMutableString *) smtp4URLString
|
||||
{
|
||||
NSMutableString *smtp4URLString;
|
||||
NSDictionary *mailAccount;
|
||||
NSString *encryption, *protocol, *smtpServerName;
|
||||
int defaultPort, port;
|
||||
|
||||
mailAccount = [self _mailAccount];
|
||||
smtpServerName = [mailAccount objectForKey: @"smtpServerName"];
|
||||
if(!smtpServerName)
|
||||
return nil; //Auxiliary account can be only configured for imap and not smtp
|
||||
encryption = [mailAccount objectForKey: @"smtpEncryption"];
|
||||
defaultPort = 25;
|
||||
protocol = @"smtp";
|
||||
|
||||
if ([encryption isEqualToString: @"ssl"])
|
||||
{
|
||||
protocol = @"smtps";
|
||||
defaultPort = 465;
|
||||
}
|
||||
else if ([encryption isEqualToString: @"tls"])
|
||||
{
|
||||
protocol = @"smtps";
|
||||
defaultPort = 465;
|
||||
}
|
||||
|
||||
smtp4URLString = [NSMutableString stringWithFormat: @"%@://%@", protocol, smtpServerName];
|
||||
port = [[mailAccount objectForKey: @"smtpPort"] intValue];
|
||||
if (port && port != defaultPort)
|
||||
[smtp4URLString appendFormat: @":%d", port];
|
||||
|
||||
[smtp4URLString appendString: @"/"];
|
||||
|
||||
return smtp4URLString;
|
||||
}
|
||||
|
||||
- (NSMutableString *) traversalFromMailAccount
|
||||
{
|
||||
return [NSMutableString string];
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
@interface SOGoMailBaseObject : SOGoObject
|
||||
{
|
||||
NSURL *imap4URL;
|
||||
NSURL *smtp4URL;
|
||||
NGImap4Connection *imap4;
|
||||
BOOL imap4ExceptionsEnabled;
|
||||
}
|
||||
@@ -74,6 +75,7 @@
|
||||
- (NSMutableString *) traversalFromMailAccount;
|
||||
|
||||
- (NSURL *) imap4URL;
|
||||
- (NSURL *) smtp4URL;
|
||||
- (NSString *) imap4PasswordRenewed: (BOOL) renew;
|
||||
|
||||
- (void) flushMailCaches;
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
- (void) dealloc
|
||||
{
|
||||
[imap4URL release];
|
||||
[smtp4URL release];
|
||||
[imap4 release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -317,6 +318,35 @@
|
||||
return imap4URL;
|
||||
}
|
||||
|
||||
- (NSURL *) smtp4URL
|
||||
{
|
||||
SOGoMailAccount *account;
|
||||
NSString *urlString, *smtpUrl;
|
||||
NSString *useTls = @"NO";
|
||||
|
||||
/* this could probably be handled better from NSURL but it's buggy in
|
||||
GNUstep */
|
||||
if (!smtp4URL)
|
||||
{
|
||||
account = [self mailAccountFolder];
|
||||
smtpUrl = [account smtp4URLString];
|
||||
if(smtpUrl)
|
||||
{
|
||||
if ([[account smtpEncryption] isEqualToString: @"tls"])
|
||||
{
|
||||
useTls = @"YES";
|
||||
}
|
||||
urlString = [NSString stringWithFormat: @"%@?tls=%@&tlsVerifyMode=%@",
|
||||
smtpUrl, useTls, [account smtpTlsVerifyMode]];
|
||||
smtp4URL = [[NSURL alloc] initWithString: urlString];
|
||||
}
|
||||
else
|
||||
smtp4URL = nil;
|
||||
}
|
||||
|
||||
return smtp4URL;
|
||||
}
|
||||
|
||||
- (NSString *) imap4PasswordRenewed: (BOOL) renewed
|
||||
{
|
||||
return [[self mailAccountFolder] imap4PasswordRenewed: renewed];
|
||||
|
||||
Reference in New Issue
Block a user