diff options
author | Dmitry Isaikin <isaikin@corp.mail.ru> | 2016-02-02 19:23:58 +0300 |
---|---|---|
committer | Dmitry Isaikin <isaikin@corp.mail.ru> | 2016-02-09 15:53:40 +0300 |
commit | f9cdd2e6193cddfa405723eb70dda9261b26848d (patch) | |
tree | 0448dfc39864b9d52b55d5ad7a91d16d15bb2c71 /src/objc/smtp | |
parent | 908b7d4b8fdd7be43687450a36d56a6fb905ca25 (diff) |
Add file-based interface for sending messages via SMTP (reduce memory usage)
Diffstat (limited to 'src/objc/smtp')
-rw-r--r-- | src/objc/smtp/MCOSMTPSession.h | 18 | ||||
-rw-r--r-- | src/objc/smtp/MCOSMTPSession.mm | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h index 31055335..84d6949d 100644 --- a/src/objc/smtp/MCOSMTPSession.h +++ b/src/objc/smtp/MCOSMTPSession.h @@ -154,6 +154,24 @@ from:(MCOAddress *)from recipients:(NSArray *)recipients; + +/** + Returns an operation that will send the message from the given file through SMTP. + It will use the sender and recipient set from the parameters. + It will also filter out Bcc from the content of the message. + + MCOSMTPOperation * op = [session sendOperationWithContentsOfFile:rfc822DataFilename + from:[MCOAddress addressWithMailbox:@"hoa@etpan.org"] + recipients:[NSArray arrayWithObject: + [MCOAddress addressWithMailbox:@"laura@etpan.org"]]]; + [op start:^(NSError * __nullable error) { + ... + }]; + */ +- (MCOSMTPSendOperation *) sendOperationWithContentsOfFile:(NSString *)path + from:(MCOAddress *)from + recipients:(NSArray *)recipients; + /** Returns an operation that will check whether the SMTP account is valid. diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm index 9bcbd48e..9406a719 100644 --- a/src/objc/smtp/MCOSMTPSession.mm +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -170,6 +170,19 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, return result; } +- (MCOSMTPSendOperation *) sendOperationWithContentsOfFile:(NSString *)path + from:(MCOAddress *)from + recipients:(NSArray *)recipients +{ + mailcore::SMTPOperation * coreOp = + MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(Address, from), + MCO_FROM_OBJC(Array, recipients), + MCO_FROM_OBJC(String, path)); + MCOSMTPSendOperation * result = [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease]; + [result setSession:self]; + return result; +} + - (MCOSMTPOperation *) checkAccountOperationWithFrom:(MCOAddress *)from { mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from)); |