SwiftMandrill 1.0.4

SwiftMandrill 1.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2016
SPMSupports SPM

Maintained by Chris Jimenez.



 
Depends on:
ObjectMapper~> 1.1
Alamofire~> 3.0
 

SwiftMandrill

SwiftMandrill provides simple alternative when you need to send an email with your iOS app.

:question: Why?

Sometimes, there is the need to setup a simple email form in your iOS app, or trigger an email after an action, without having to setup your own service for that, sometimes you don’t want to use the MailComposeViewController or use a SMTP library. This provide a simple alternative when you need to send an email with your iOS app.

:monkey: Mandrill

Mandrill provides a simple reliable API for transactional emails. You will need to have a Mandrill account to use the client and a API key.

:octocat: Installation

Get SwiftMandrill on CocoaPods, just add pod 'SwiftMandrill' to your Podfile.

:mortar_board: Usage

Usage is very simple

let api = MandrillAPI(ApiKey: "YourApiKey")

api.sendEmail(from:    "[email protected]",
              fromName:"Chris Jimenez",
              to:      "[email protected]",
              subject: "My subject",
              html:    "<b>This is a Test</b>",
              text:    "This is a test"){ mandrillResult in
    if mandrillResult.success {
      print("Email was sent!")
    }
}

You can also send an email to several recipients by passing an array

let api = MandrillAPI(ApiKey: "YourApiKey")

api.sendEmail(from:    "[email protected]",
              fromName:"Chris Jimenez",
              to:      ["[email protected]","[email protected]"],
              subject: "My subject",
              html:    "<b>This is a Test</b>",
              text:    "This is a test"){ mandrillResult in
    if mandrillResult.success {
      print("Email was sent!")
    }
}

If inline parameters is not your thing you can also provide a MandrillEmail object and send that one

let api = MandrillAPI(ApiKey: "YourApiKey")

let email     = MandrillEmail()
email.from    = "[email protected]"
email.fromName= "Chris Jimenez"
email.to      = "[email protected]"
email.subject = "this is a test"
email.html    = "<b><Test/b>"
email.text    = "Test"   

 api.sendEmail(withEmail: email){ mandrillResult in
    if mandrillResult.success {
      print("Email was sent!"")
    }
}

:wrench: TODO

  • Most of the API is still not cover, stuff like tracking, templates, search, etc will be a nice addition.

  • Carthage support

:v: License

MIT

:alien: Author

Chris Jimenez - http://chrisjimenez.net, @chrisjimeneznat