Skip to content

Instantly share code, notes, and snippets.

@tgpfeiffer
Created November 30, 2012 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgpfeiffer/4176366 to your computer and use it in GitHub Desktop.
Save tgpfeiffer/4176366 to your computer and use it in GitHub Desktop.
Send Email from Lift
tryo {
MyMailer.sendMail(
MyMailer.From("info@mysite.de"),
MyMailer.Subject(subject),
(MyMailer.MessageHeader("Date", now.toGMTString()) ::
MyMailer.PlainPlusBodyType(formattedContent, "utf-8") ::
MyMailer.XHTMLMailBodyType(htmlContent) ::
recipients.map(MyMailer.To(_))
): _*)
} match {
case Failure(message, exception, chain) =>
logger.error("problem while sending email: " + message)
case _ =>
logger.info("successfully sent email")
}
object MyMailer extends Mailer {
/*override lazy val devModeSend = testModeSend
override lazy val stagingModeSend = testModeSend*/
authenticator = for {
user <- Props.get("mail.user")
pass <- Props.get("mail.password")
} yield new Authenticator {
logger.info("setting up password authentication")
override def getPasswordAuthentication =
new PasswordAuthentication(user, pass)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment