This library allows you to quickly and easily send emails through SendGrid using Objective-C.
Important: This library requires AFNetworking 2.0 or higher.
sendgrid *msg = [sendgrid user:@"username" andPass:@"password"];
msg.to = @"[email protected]";
msg.subject = @"subject goes here";
msg.from = @"[email protected]";
msg.text = @"hello world";
msg.html = @"<h1>hello world!</h1>";
[msg sendWithWeb];
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SendGrid and its dependencies in your projects. Simply add the lines below to your existing Podfile or make a new 'Podfile' that contain the lines below.
platform :ios, '7.0'
pod 'sendgrid', '~> 0.1.0'
Run the following in the command line
pod install
Be sure to open up the xcworkspace file now instead of the xcodeproj file.
Install via Source
1. Clone this repository.
2. Copy sendgrid.m and .h files to your project.
3. Import both sendgrid and AFNetworking in your project
To begin using this library, create a new email object with your SendGrid credentials.
sendgrid *msg = [sendgrid user:@"username" andPass:@"password"];
Customize the parameters of your email message.
msg.tolist = @[@"[email protected]", @"[email protected]"];
msg.subject = @"subject goes here";
msg.from = @"[email protected]";
msg.text = @"hello world";
msg.html = @"<h1>hello world!</h1>";
For the full list of available parameters, check out the Docs
You can add a single address using the to property of the mail object
msg.to = @"[email protected]";
Or
You can add multiple To addresses by setting the toList property
msg.tolist = @[@"[email protected]", @"[email protected]"];
Note One or the other must be set.
You can add an image attachment to your email message. The method accepts a UIImage.
[msg attachImage:self.photo];
Displaying attached image inline
msg.inlinePhoto = true;
msg.html = @"<img src =\"cid:image.png\"><h1>hello world</h1>";
You can set custom headers in your email by using the addCustomHeader:withKey method.
Adding Categories
NSString *cat = @"billing_notifications";
[msg addCustomHeader:cat withKey:@"category"];
Adding Unique Arguments
NSDictionary *uarg = @{@"customerAccountNumber":@"55555",
@"activationAttempt": @"1"};
[msg addCustomHeader:uarg withKey:@"unique_args"];
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request