aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/async/smtp/MCSMTPAsyncSession.cc11
-rw-r--r--src/async/smtp/MCSMTPAsyncSession.h2
-rw-r--r--src/async/smtp/MCSMTPSendWithDataOperation.cc31
-rw-r--r--src/async/smtp/MCSMTPSendWithDataOperation.h8
-rw-r--r--src/core/smtp/MCSMTPSession.h4
-rw-r--r--src/objc/smtp/MCOSMTPSession.h18
-rw-r--r--src/objc/smtp/MCOSMTPSession.mm13
7 files changed, 84 insertions, 3 deletions
diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc
index f670894a..4da41b5d 100644
--- a/src/async/smtp/MCSMTPAsyncSession.cc
+++ b/src/async/smtp/MCSMTPAsyncSession.cc
@@ -211,6 +211,17 @@ SMTPOperation * SMTPAsyncSession::sendMessageOperation(Data * messageData)
return (SMTPOperation *) op->autorelease();
}
+SMTPOperation * SMTPAsyncSession::sendMessageOperation(Address * from, Array * recipients,
+ Data * messageData)
+{
+ SMTPSendWithDataOperation * op = new SMTPSendWithDataOperation();
+ op->setSession(this);
+ op->setMessageData(messageData);
+ op->setFrom(from);
+ op->setRecipients(recipients);
+ return (SMTPOperation *) op->autorelease();
+}
+
SMTPOperation * SMTPAsyncSession::checkAccountOperation(Address * from)
{
SMTPCheckAccountOperation * op = new SMTPCheckAccountOperation();
diff --git a/src/async/smtp/MCSMTPAsyncSession.h b/src/async/smtp/MCSMTPAsyncSession.h
index bbb81737..f013dc26 100644
--- a/src/async/smtp/MCSMTPAsyncSession.h
+++ b/src/async/smtp/MCSMTPAsyncSession.h
@@ -55,6 +55,8 @@ namespace mailcore {
virtual ConnectionLogger * connectionLogger();
virtual SMTPOperation * sendMessageOperation(Data * messageData);
+ virtual SMTPOperation * sendMessageOperation(Address * from, Array * recipients,
+ Data * messageData);
virtual SMTPOperation * checkAccountOperation(Address * from);
public: // private
diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.cc b/src/async/smtp/MCSMTPSendWithDataOperation.cc
index bb2c5ea9..03f6a530 100644
--- a/src/async/smtp/MCSMTPSendWithDataOperation.cc
+++ b/src/async/smtp/MCSMTPSendWithDataOperation.cc
@@ -16,10 +16,14 @@ using namespace mailcore;
SMTPSendWithDataOperation::SMTPSendWithDataOperation()
{
mMessageData = NULL;
+ mFrom = NULL;
+ mRecipients = NULL;
}
SMTPSendWithDataOperation::~SMTPSendWithDataOperation()
{
+ MC_SAFE_RELEASE(mFrom);
+ MC_SAFE_RELEASE(mRecipients);
MC_SAFE_RELEASE(mMessageData);
}
@@ -33,9 +37,34 @@ Data * SMTPSendWithDataOperation::messageData()
return mMessageData;
}
+void SMTPSendWithDataOperation::setFrom(Address * from)
+{
+ MC_SAFE_REPLACE_COPY(Address, mFrom, from);
+}
+
+Address * SMTPSendWithDataOperation::from()
+{
+ return mFrom;
+}
+
+void SMTPSendWithDataOperation::setRecipients(Array * recipients)
+{
+ MC_SAFE_REPLACE_COPY(Array, mRecipients, recipients);
+}
+
+Array * SMTPSendWithDataOperation::recipients()
+{
+ return mRecipients;
+}
+
void SMTPSendWithDataOperation::main()
{
ErrorCode error;
- session()->session()->sendMessage(mMessageData, this, &error);
+ if ((mFrom != NULL) && (mRecipients != NULL)) {
+ session()->session()->sendMessage(mFrom, mRecipients, mMessageData, this, &error);
+ }
+ else {
+ session()->session()->sendMessage(mMessageData, this, &error);
+ }
setError(error);
}
diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.h b/src/async/smtp/MCSMTPSendWithDataOperation.h
index afa1a5e0..6c407bb3 100644
--- a/src/async/smtp/MCSMTPSendWithDataOperation.h
+++ b/src/async/smtp/MCSMTPSendWithDataOperation.h
@@ -23,6 +23,12 @@ namespace mailcore {
SMTPSendWithDataOperation();
virtual ~SMTPSendWithDataOperation();
+ virtual void setFrom(Address * from);
+ virtual Address * from();
+
+ virtual void setRecipients(Array * recipients);
+ virtual Array * recipients();
+
virtual void setMessageData(Data * data);
virtual Data * messageData();
@@ -31,6 +37,8 @@ namespace mailcore {
private:
Data * mMessageData;
+ Array * mRecipients;
+ Address * mFrom;
};
}
diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h
index 3d066a6c..1b4c9690 100644
--- a/src/core/smtp/MCSMTPSession.h
+++ b/src/core/smtp/MCSMTPSession.h
@@ -58,6 +58,8 @@ namespace mailcore {
virtual void checkAccount(Address * from, ErrorCode * pError);
virtual void sendMessage(Data * messageData, SMTPProgressCallback * callback, ErrorCode * pError);
+ virtual void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData,
+ SMTPProgressCallback * callback, ErrorCode * pError);
virtual void setConnectionLogger(ConnectionLogger * logger);
virtual ConnectionLogger * connectionLogger();
@@ -93,8 +95,6 @@ namespace mailcore {
void loginIfNeeded(ErrorCode * pError);
bool checkCertificate();
- void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData,
- SMTPProgressCallback * callback, ErrorCode * pError);
void sendMessage(MessageBuilder * msg, SMTPProgressCallback * callback, ErrorCode * pError);
public: // private
diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h
index bb7c5f57..6716ee30 100644
--- a/src/objc/smtp/MCOSMTPSession.h
+++ b/src/objc/smtp/MCOSMTPSession.h
@@ -93,6 +93,24 @@
- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData;
/**
+ Returns an operation that will send the given message 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.
+
+ Generate RFC 822 data using MCOMessageBuilder
+
+ MCOPOPOperation * op = [session sendOperationWithData:rfc822Data
+ from:[MCOAddress addressWithMailbox:@"hoa@etpan.org"]
+ recipients:[NSArray arrayWithObject:[MCOAddress addressWithMailbox:@"laura@etpan.org"]]];
+ [op start:^(NSError * error) {
+ ...
+ }];
+ */
+- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData
+ from:(MCOAddress *)from
+ recipients:(NSArray *)recipients;
+
+/**
Returns an operation that will check whether the SMTP account is valid.
MCOPOPOperation * op = [session checkAccountOperationWithFrom:[MCOAddress addressWithMailbox:@"hoa@etpan.org"]];
diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm
index c9f9f0fc..0c24f66c 100644
--- a/src/objc/smtp/MCOSMTPSession.mm
+++ b/src/objc/smtp/MCOSMTPSession.mm
@@ -109,6 +109,19 @@ MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled)
return result;
}
+- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData
+ from:(MCOAddress *)from
+ recipients:(NSArray *)recipients
+{
+ mailcore::SMTPOperation * coreOp =
+ MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(Address, from),
+ MCO_FROM_OBJC(Array, recipients),
+ [messageData mco_mcData]);
+ MCOSMTPSendOperation * result = [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease];
+ [result setSession:self];
+ return result;
+}
+
- (MCOOperation *) checkAccountOperationWithFrom:(MCOAddress *)from
{
mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from));