lift-mandrill


License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

com.hacklanta
ArtifactId

ArtifactId

lift-mandrill_2.10
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

lift-mandrill
lift-mandrill
Project URL

Project URL

https://github.com/hacklanta/lift-mandrill
Project Organization

Project Organization

com.hacklanta
Source Code Management

Source Code Management

https://github.com/hacklanta/lift-mandrill.git

Download lift-mandrill_2.10

How to add to project

<!-- https://jarcasting.com/artifacts/com.hacklanta/lift-mandrill_2.10/ -->
<dependency>
    <groupId>com.hacklanta</groupId>
    <artifactId>lift-mandrill_2.10</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.hacklanta/lift-mandrill_2.10/
implementation 'com.hacklanta:lift-mandrill_2.10:0.1.1'
// https://jarcasting.com/artifacts/com.hacklanta/lift-mandrill_2.10/
implementation ("com.hacklanta:lift-mandrill_2.10:0.1.1")
'com.hacklanta:lift-mandrill_2.10:jar:0.1.1'
<dependency org="com.hacklanta" name="lift-mandrill_2.10" rev="0.1.1">
  <artifact name="lift-mandrill_2.10" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.hacklanta', module='lift-mandrill_2.10', version='0.1.1')
)
libraryDependencies += "com.hacklanta" % "lift-mandrill_2.10" % "0.1.1"
[com.hacklanta/lift-mandrill_2.10 "0.1.1"]

Dependencies

compile (6)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.4
net.liftweb : lift-common_2.10 jar 2.6-RC1
net.liftweb : lift-util_2.10 jar 2.6-RC1
net.liftweb : lift-json_2.10 jar 2.6-RC1
net.databinder.dispatch : dispatch-core_2.10 jar 0.11.2
net.databinder.dispatch : dispatch-lift-json_2.10 jar 0.11.2

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.10 jar 2.2.1

Project Modules

There are no modules declared in this project.

lift-mandrill

This is a useful library for using Mandrill with Lift. It uses lift-json and Databinder's dispatch to make interacting with the Mandrill API pretty painless.

Configuration

You'll need to add the following configuration parameters to your props file that Lift uses.

  • mandrill.apiKey (required) - Your API key for Mandrill.
  • mandrill.endpointHost (optional) - Some host other than mandrillapp.com, if needed.
  • mandrill.apiVersion (optional) - Some version other than 1.0, if needed.

Usage

To use the Mandrill API to send an email, you need to invoke Mandrill.run and pass in an instance of MandrillApiCall.

// At the top of your file
import com.hacklanta.mandrill._

// In your code that needs to invoke Mandrill
Mandrill.run(...)

The Mandill.run method will log in the event something goes wrong, but will never return anything. (Something that will be fixed in the future at some point.)

Sending a regular email

To send an email using the Mandrill API, you create an instance of a MandrillMessage, create a SendMandrillMessage then pass that to Mandrill.run.

Mandrill.run(SendMandrillMessage(MandrillMessage(
  subject = "My subject",
  from_email = "[email protected]",
  to = List(
    MandrillTo("[email protected]", Some("recipient name if provided"), "to") //last param could be "cc" or "bcc"
  ),
  html = Some(...), // HTML version
  text = Some(...)  // plain text version
)))

Sending a templated email

To send an email with a template on your Mandrill account, you need to know the template name, and the name of the mc:edit regions in the email. Once you have that, you can invoke SendTemplateMandrillMessage.

Mandrill.run(SendTemplateMandrillMessage(
  MandrillMessage(
    subject = "...",
    from_email = "...",
    to = List(...)
  ),
  template_name = "My awesome template.",
  template_content = List(
    Map("name" -> "edit region 1", "content" -> "..."),
    Map("name" -> "edit region 2", "content" -> "...")
  )
))
com.hacklanta

Hacklanta

Code as craft in the ATL.

Versions

Version
0.1.1
0.1.0