URL: http://vafer.org/blog/20080604120118
With 10.5 Apple deprecated the use of NSMailDelivery – without a replacement. So the questions comes up regulary – how does one send emails from Cocoa? Turns out there are couple of frameworks available that can also be used to do the job.
- Pantomime (LGPL license) - http://www.collaboration-world.com/pantomime/
- MailCore (New BSD license) - http://www.mronge.com/m/MailCore/
- EDMessage (BSD syle license) - http://www.mulle-kybernetik.com/software/EDFrameworks/download.html#EDMessage
EDMessage has been around for ages. Checkout the example on how to use the API. MailCore is also really easy to use. But both lack support for asynchronous mail delivery. With MailCore I couldn’t even work out how to send attachments. Also no idea if it’s getting developed anymore. So if you are OK to use a LGPL library Pantomime seemed like a good choice. Sending simple emails is quite straight forward.
CWMessage *message = [[CWMessage alloc] init]; CWInternetAddress *address; [message setFrom:address]; [address release]; [address setType:PantomimeToRecipient]; [message addRecipient:address]; [address release]; [message setSubject:@"test"]; [message setContentType: @"text/plain"]; [message setContentTransferEncoding: PantomimeEncodingNone]; [message setCharset: @"us-ascii"]; [message setContent: [@"This is a simple content." dataUsingEncoding: NSASCIIStringEncoding]]; smtp = [[CWSMTP alloc] initWithName:@"smtp.gmail.com" port:465]; [smtp setDelegate: self]; [smtp setMessage: message]; [message release]; ssl = YES; mechanism = @"PLAIN"; [smtp connectInBackgroundAndNotify];
You need to login to post a comment.
