I'm new to scala and lift, and I've been hacking with a LiftActor used to a local mail server for development based on the post by Ryan Donahue: http://groups.google.com/group/liftweb/browse_thread/thread/56002b39aa67aee6/4d3946d145560d3e?lnk=gst&q=test+mail#4d3946d145560d3e
However the code in that post uses ActorPing.scheduledAtFixedRate which has been removed in the lift 1.1-M8 which I'm using, and it also looks like LiftActors are now the preferred actor library to use. Question 1: Given that my LiftActor has to do some cleanup at shutdown, is a LiftActor even appropriate or should I look at regular scala actors? If LiftActor is still usable in that scenario, how can my LiftActor get a notification that it needs to do cleanup? The particular problem I'm having is that Jetty restarts when I change code, but the smtp server is still bound to the mail port so the restart fails. I need to stop the mail server when Jetty restarts. Question 2: Is there an easier way to configure mail locally for development? I know I could create a gmail account and put the credentials in Boot.scala, but I was hoping for something self- contained on my local machine. Here's my code if that helps (probably not since I'm new to scala it is probably pretty bad): package com.chariotsolutions.liftexpo import scala.collection.jcl.MutableIterator.Wrapper import net.liftweb.util._ import net.liftweb.util.Helpers._ import net.liftweb.actor._ import net.liftweb.common._ import com.dumbster.smtp._ object DumbMail extends LiftActor { private var server : Box[SimpleSmtpServer] = Empty private var port : Int = 25 implicit def javaIteratorToScalaIterator[A](it : java.util.Iterator [A]) = new Wrapper(it) def boot(port:Int) = { println("DumbMail booting") this.port = port restartServer ActorPing.schedule(this, DumbMailEvent, 5 seconds) } private def restartServer { stopServer server = Full(SimpleSmtpServer.start(port)) } private def stopServer { server.map(_.stop) server = Empty } protected def messageHandler = { case DumbMailEvent => { println("DumbMailEvent received") server match { case Full(s) => { if (s.getReceivedEmailSize > 0) { //val msgs = new Wrapper(s.getReceivedEmail) //val msgs = new IteratorWrapper (s.getReceivedEmail.asInstanceOf [java.util.Iterator[SmtpMessage]]) for (anyMsg <- s.getReceivedEmail) { val msg = anyMsg.asInstanceOf[SmtpMessage] println("RECEIVED EMAIL ---------------------------------------") println("From: " + msg.getHeaderValue("From")) println("To: " + msg.getHeaderValue("To")) println("Subject: " + msg.getHeaderValue ("Subject")) println("Body: " + msg.getBody) println ("------------------------------------------------------") } restartServer // reset state } } case _ => // do nothing } } ActorPing.schedule(this, DumbMailEvent, 5 seconds) case _ => println("Unexpected event received") } } case object DumbMailEvent
-- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.