deliver electronic mail with scala from the future
Via the copy and paste method
resolvers += "softprops-maven" at "http://dl.bintray.com/content/softprops/maven"
libraryDependencies += "me.lessis" %% "courier" % "0.1.2"
Via a more civilized method which will do the same without all the manual work.
> ls-install courier
Note. If you are a bintray-sbt user you can optionally specify the resolver as
resolvers += bintray.Opts.resolver.repo("softprops", "maven")
deliver electronic mail via gmail
import courier._, Defaults._
val mailer = Mailer("smtp.gmail.com", 587)
.auth(true)
.as("you@gmail.com", "p@$$w3rd")
.startTtls(true)()
mailer(Envelope.from("you" `@` "gmail.com")
.to("mom" `@` "gmail.com")
.cc("dad" `@` "gmail.com")
.subject("miss you")
.content(Text("hi mom"))).onSuccess {
case _ => println("message delivered")
}
mailer(Envelope.from("you" `@` "work.com")
.to("boss" `@` "work.com")
.subject("tps report")
.content(Multipart()
.attach(new java.io.File("tps.xls"))
.html("<html><body><h1>IT'S IMPORTANT</h1></body></html>")))
.onSuccess {
case _ => println("delivered report")
}
Doug Tangren (softprops) 2013