Skip to content

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

License

Notifications You must be signed in to change notification settings

PiXeL16/SwiftMandrill

Repository files navigation

SwiftMandrill Build Status codecov.io CocoaPods Compatible GitHub license

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.

🐒 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.

🎓 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!"")
    }
}

🔧 TODO

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

  • Carthage support

✌️ License

MIT

👽 Author

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •