Most ESPs make sending email through their services super easy. On top of that, we at SendGrid have libraries for most languages/frameworks like, Node, C#, Java, etc. Last year Kunal Batra created the Objective-C library, and we had great feedback from a lot of people saying how easy it was to use.
During the past couple weeks I spent some time working on the Objective-C library, and getting it more up-to-date with the others. Now, as in other languages, we have a library called “SMTPAPI,” which helps easily build the X-SMTPAPI headers for additional functionality while sending email. We also have the SendGrid library that contains an object called SendGrid, which takes care of authentication and sending email. Finally, we have a class called SendGridEmail, which is the object representing the email, which contains to, from, text, html, and the SMTPAPI header.
Now, to start using the library all you needs it to create a new project in XCode, then navigate to your project’s folder in your terminal and run:
After opening the Podfile in your text editor, add the following line to it:
Make sure you pay attention to the casing, then go back to your terminal, and run:
That will add the SendGrid, SMTPAPI, and AFNetworking libraries to your project. To start sending email, all you have to do is import the library into your class:
And then you can easily send an email by doing:
Change the username and password with your own credentials. I reccomend creating different credentials for each app you work on.
Here’s a sample project using the new library, so you can easily integrate it into your awesome apps.