Created
November 30, 2012 15:19
-
-
Save tgpfeiffer/4176366 to your computer and use it in GitHub Desktop.
Send Email from Lift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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