Monotone-Parent: 753e863b1e3ac69df91f82bcd8d13909de69ea5b
Monotone-Revision: f5375423b8629730c6f88e76c660c389426c1f5a Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-09-26T15:49:11 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
ec515b984e
commit
34f3b7a0a9
|
@ -1,5 +1,10 @@
|
|||
2011-09-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoDraftObject.m (-sendMailAndCopyToSent:):
|
||||
renamed "sendMail" and made copying the messsage to the sent
|
||||
folder opetional.
|
||||
(-sendMail): new method that invokes the above one with "yes".
|
||||
|
||||
* OpenChange/MAPIStoreMemMailMessage.m (-save): fixed "subject"
|
||||
header, "to" and other recipients. Fixed "content-type", that was
|
||||
deduced after "message" was generated. Take the client-provided
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
|
||||
- (NSException *) delete;
|
||||
- (NSException *) sendMail;
|
||||
- (NSException *) sendMailAndCopyToSent: (BOOL) copyToSent; /* default: YES */
|
||||
- (NSException *) save;
|
||||
|
||||
// /* fake being a SOGoMailObject */
|
||||
|
|
|
@ -1515,6 +1515,11 @@ static NSString *userAgent = nil;
|
|||
}
|
||||
|
||||
- (NSException *) sendMail
|
||||
{
|
||||
return [self sendMailAndCopyToSent: YES];
|
||||
}
|
||||
|
||||
- (NSException *) sendMailAndCopyToSent: (BOOL) copyToSent
|
||||
{
|
||||
NSMutableData *cleaned_message;
|
||||
SOGoMailFolder *sentFolder;
|
||||
|
@ -1525,65 +1530,67 @@ static NSString *userAgent = nil;
|
|||
NSRange r1, r2;
|
||||
|
||||
/* send mail */
|
||||
sentFolder = [[self mailAccountFolder] sentFolderInContext: context];
|
||||
if ([sentFolder isKindOfClass: [NSException class]])
|
||||
error = (NSException *) sentFolder;
|
||||
else
|
||||
{
|
||||
// We strip the BCC fields prior sending any mails
|
||||
NGMimeMessageGenerator *generator;
|
||||
|
||||
generator = [[[NGMimeMessageGenerator alloc] init] autorelease];
|
||||
message = [generator generateMimeFromPart: [self mimeMessageWithHeaders: nil
|
||||
excluding: nil]];
|
||||
// We strip the BCC fields prior sending any mails
|
||||
NGMimeMessageGenerator *generator;
|
||||
|
||||
generator = [[[NGMimeMessageGenerator alloc] init] autorelease];
|
||||
message = [generator generateMimeFromPart: [self mimeMessageWithHeaders: nil
|
||||
excluding: nil]];
|
||||
|
||||
//
|
||||
// We now look for the Bcc: header. If it is present, we remove it.
|
||||
// Some servers, like qmail, do not remove it automatically.
|
||||
//
|
||||
//
|
||||
// We now look for the Bcc: header. If it is present, we remove it.
|
||||
// Some servers, like qmail, do not remove it automatically.
|
||||
//
|
||||
#warning FIXME - we should fix the case issue when we switch to Pantomime
|
||||
cleaned_message = [NSMutableData dataWithData: message];
|
||||
r1 = [cleaned_message rangeOfCString: "\r\n\r\n"];
|
||||
r1 = [cleaned_message rangeOfCString: "\r\nbcc: "
|
||||
options: 0
|
||||
range: NSMakeRange(0,r1.location-1)];
|
||||
cleaned_message = [NSMutableData dataWithData: message];
|
||||
r1 = [cleaned_message rangeOfCString: "\r\n\r\n"];
|
||||
r1 = [cleaned_message rangeOfCString: "\r\nbcc: "
|
||||
options: 0
|
||||
range: NSMakeRange(0,r1.location-1)];
|
||||
|
||||
if (r1.location != NSNotFound)
|
||||
{
|
||||
// We search for the first \r\n AFTER the Bcc: header and
|
||||
// replace the whole thing with \r\n.
|
||||
r2 = [cleaned_message rangeOfCString: "\r\n"
|
||||
options: 0
|
||||
range: NSMakeRange(NSMaxRange(r1)+1,[cleaned_message length]-NSMaxRange(r1)-1)];
|
||||
[cleaned_message replaceBytesInRange: NSMakeRange(r1.location, NSMaxRange(r2)-r1.location)
|
||||
withBytes: "\r\n"
|
||||
length: 2];
|
||||
}
|
||||
if (r1.location != NSNotFound)
|
||||
{
|
||||
// We search for the first \r\n AFTER the Bcc: header and
|
||||
// replace the whole thing with \r\n.
|
||||
r2 = [cleaned_message rangeOfCString: "\r\n"
|
||||
options: 0
|
||||
range: NSMakeRange(NSMaxRange(r1)+1,[cleaned_message length]-NSMaxRange(r1)-1)];
|
||||
[cleaned_message replaceBytesInRange: NSMakeRange(r1.location, NSMaxRange(r2)-r1.location)
|
||||
withBytes: "\r\n"
|
||||
length: 2];
|
||||
}
|
||||
|
||||
dd = [[context activeUser] domainDefaults];
|
||||
error = [[SOGoMailer mailerWithDomainDefaults: dd]
|
||||
dd = [[context activeUser] domainDefaults];
|
||||
error = [[SOGoMailer mailerWithDomainDefaults: dd]
|
||||
sendMailData: cleaned_message
|
||||
toRecipients: [self allBareRecipients]
|
||||
sender: [self sender]];
|
||||
if (!error)
|
||||
{
|
||||
error = [sentFolder postData: message flags: @"seen"];
|
||||
if (!error)
|
||||
{
|
||||
[self imap4Connection];
|
||||
if (IMAP4ID > -1)
|
||||
[imap4 markURLDeleted: [self imap4URL]];
|
||||
if (sourceURL && sourceFlag)
|
||||
{
|
||||
sourceIMAP4URL = [NSURL URLWithString: sourceURL];
|
||||
[imap4 addFlags: sourceFlag toURL: sourceIMAP4URL];
|
||||
}
|
||||
if (![dd mailKeepDraftsAfterSend])
|
||||
error = [self delete];
|
||||
}
|
||||
}
|
||||
if (!error && copyToSent)
|
||||
{
|
||||
sentFolder = [[self mailAccountFolder] sentFolderInContext: context];
|
||||
if ([sentFolder isKindOfClass: [NSException class]])
|
||||
error = (NSException *) sentFolder;
|
||||
else
|
||||
{
|
||||
error = [sentFolder postData: message flags: @"seen"];
|
||||
if (!error)
|
||||
{
|
||||
[self imap4Connection];
|
||||
if (IMAP4ID > -1)
|
||||
[imap4 markURLDeleted: [self imap4URL]];
|
||||
if (sourceURL && sourceFlag)
|
||||
{
|
||||
sourceIMAP4URL = [NSURL URLWithString: sourceURL];
|
||||
[imap4 addFlags: sourceFlag toURL: sourceIMAP4URL];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!error && ![dd mailKeepDraftsAfterSend])
|
||||
[self delete];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue