/CGLMail

A simple class that cares about email and MessageUI, so you don't have to

Primary LanguageObjective-CMIT LicenseMIT

CGLMail

CGLMail makes it easy to send email from any class in your app, without implementing the MFMailComposeViewControllerDelegate protocol all over the place. It was initially written to centralize the submission of feedback emails into one class.

Usage

If you're using cocoapods like you should, add CGLMail to your podfile:

pod 'CGLMail', '~> 0.1'

For example, you can get a view controller to send an email like so:

UIViewController *mailVC = [CGLMailHelper mailViewControllerWithRecipients:@[@"my@mom.com"] 
                                                                   subject:@"Hi Mom!" 
                                                                   message:@"Hi Mom, \n\nJust wanted to check in and say hello!\n\nLove, \nChris" 
                                                                    isHTML:NO 
                                                            includeAppInfo:NO 
                                                                completion:nil];

Which would end up looking somthing like this:

Support Screenshot

Or, to generate a user support email, with diagnostic info about the user's app and device:

UIViewController *mailVC = [CGLMailHelper supportMailViewControllerWithRecipient:@"support@support.com" 
                                                                         subject:@"Support Email" 
                                                                      completion:nil];

Which would yield a view controller that looks like this:

Support Screenshot

Safety First

Note that CGLMailHelper will return nil if [MFMailComposeViewController canSendMail] returns NO, e.g. if the user has not yet set up her email address. Be sure to check for nil! UIKit will throw an exception if you try to present a nil view controller.