From dd099c9eca5d5b56212f3d855db0755e788f422b Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Thu, 4 Nov 2010 18:34:51 +0000 Subject: [PATCH] Fix for bug #803 Monotone-Parent: c8d3bf05ef46d0c8d36879db7366c665f4dacd3d Monotone-Revision: 303b1e781872f11eb1260c7f21d6ad5e73b55be7 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2010-11-04T18:34:51 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ SoObjects/SOGo/SOGoMailer.m | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c295a459e..d2e138db7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-04 Ludovic Marcotte + + SoObjects/SOGo/SOGoMailer.m + We stop when we see an invalid recipient and we inform the + client back with what are the invalid recipients + 2010-11-04 Wolfgang Sourdeau * Tools/SOGoSockDOperation.m (_getFolderWithId:forUser:): invoke diff --git a/SoObjects/SOGo/SOGoMailer.m b/SoObjects/SOGo/SOGoMailer.m index 13cd16398..44cdffdb6 100644 --- a/SoObjects/SOGo/SOGoMailer.m +++ b/SoObjects/SOGo/SOGoMailer.m @@ -1,6 +1,6 @@ /* SOGoMailer.m - this file is part of SOGo * - * Copyright (C) 2007-2009 Inverse inc. + * Copyright (C) 2007-2010 Inverse inc. * * Author: Wolfgang Sourdeau * @@ -96,12 +96,9 @@ - (NSException *) _sendMailData: (NSData *) mailData withClient: (NGSmtpClient *) client - andRejections: (unsigned int) toErrors { NSException *result; - if (toErrors > 0) - [self logWithFormat: @"sending email despite address rejections"]; if ([client sendData: mailData]) result = nil; else @@ -118,12 +115,13 @@ { NGInternetSocketAddress *addr; NSString *currentTo, *host; + NSMutableArray *toErrors; NSEnumerator *addresses; NGSmtpClient *client; NSException *result; NSRange r; - unsigned int toErrors, port; + unsigned int port; client = [NGSmtpClient smtpClient]; host = smtpServer; @@ -145,7 +143,7 @@ { if ([client mailFrom: sender]) { - toErrors = 0; + toErrors = [NSMutableArray array]; addresses = [recipients objectEnumerator]; currentTo = [addresses nextObject]; while (currentTo) @@ -153,17 +151,21 @@ if (![client recipientTo: [currentTo pureEMailAddress]]) { [self logWithFormat: @"error with recipient '%@'", currentTo]; - toErrors++; + [toErrors addObject: [currentTo pureEMailAddress]]; } currentTo = [addresses nextObject]; } - if (toErrors == [recipients count]) + if ([toErrors count] == [recipients count]) result = [NSException exceptionWithHTTPStatus: 500 reason: @"cannot send message:" @" (smtp) all recipients discarded"]; + else if ([toErrors count] > 0) + result = [NSException exceptionWithHTTPStatus: 500 + reason: [NSString stringWithFormat: + @"cannot send message (smtp) - recipients discarded:\n%@", + [toErrors componentsJoinedByString: @", "]]]; else - result = [self _sendMailData: mailData withClient: client - andRejections: toErrors]; + result = [self _sendMailData: mailData withClient: client]; } else result = [NSException exceptionWithHTTPStatus: 500