Skip to content

Instantly share code, notes, and snippets.

@tgpfeiffer
Created November 30, 2012 15:19
Show Gist options
  • 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("[email protected]"),
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