diff --git a/ChangeLog b/ChangeLog index 42e07ba88..e386e4299 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-12-26 Ludovic Marcotte + + * SoObjects/SOGo/SOGoMailer.m (_smtpSendData: + toRecipients:sender:): We now honor the 'port' + part in the SMTP server address. So one can now + specify hostname:port (like localhost:587) as + a value of SOGoSMTPServer. This fixes + http://www.scalableogo.org/bugs/view.php?id=201 + 2009-12-25 Ludovic Marcotte * Tools/SOGoToolBackup.m (-fetchUserIDs:): diff --git a/SoObjects/SOGo/SOGoMailer.m b/SoObjects/SOGo/SOGoMailer.m index d9d40d2b9..13cd16398 100644 --- a/SoObjects/SOGo/SOGoMailer.m +++ b/SoObjects/SOGo/SOGoMailer.m @@ -30,6 +30,7 @@ #import #import #import +#import #import "NSString+Utilities.h" #import "SOGoDomainDefaults.h" @@ -115,14 +116,32 @@ toRecipients: (NSArray *) recipients sender: (NSString *) sender { + NGInternetSocketAddress *addr; + NSString *currentTo, *host; + NSEnumerator *addresses; NGSmtpClient *client; - NSEnumerator *addresses; - NSString *currentTo; - unsigned int toErrors; NSException *result; + NSRange r; + + unsigned int toErrors, port; client = [NGSmtpClient smtpClient]; - if ([client connectToHost: smtpServer]) + host = smtpServer; + port = 25; + + // We check if there is a port specified in the smtpServer ivar value + r = [smtpServer rangeOfString: @":"]; + + if (r.length) + { + port = [[smtpServer substringFromIndex: r.location+1] intValue]; + host = [smtpServer substringToIndex: r.location]; + } + + addr = [NGInternetSocketAddress addressWithPort: port + onHost: host]; + + if ([client connectToAddress: addr]) { if ([client mailFrom: sender]) {