mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +00:00
Modify smtpd to integrate with Revel.
Add plugin to app.go to start smtpd
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/robfig/revel"
|
||||
import (
|
||||
"github.com/jhillyerd/inbucket/app/smtpd"
|
||||
"github.com/robfig/revel"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
*rev.Controller
|
||||
@@ -9,3 +12,20 @@ type Application struct {
|
||||
func (c Application) Index() rev.Result {
|
||||
return c.Render()
|
||||
}
|
||||
|
||||
type SmtpdPlugin struct {
|
||||
rev.EmptyPlugin
|
||||
server *smtpd.Server
|
||||
}
|
||||
|
||||
func (p SmtpdPlugin) OnAppStart() {
|
||||
domain := rev.Config.StringDefault("smtpd.domain", "localhost")
|
||||
port := rev.Config.IntDefault("smtpd.port", 2500)
|
||||
rev.INFO.Printf("SMTP Daemon plugin init {domain: %v, port: %v}", domain, port)
|
||||
p.server = smtpd.New(domain, port)
|
||||
go p.server.Start()
|
||||
}
|
||||
|
||||
func init() {
|
||||
rev.RegisterPlugin(SmtpdPlugin{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user