WIP: mail publish
This commit is contained in:
parent
43a2acb756
commit
3001e57bcc
4 changed files with 130 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
firebase "firebase.google.com/go"
|
||||
"firebase.google.com/go/messaging"
|
||||
"fmt"
|
||||
"github.com/emersion/go-smtp"
|
||||
"google.golang.org/api/option"
|
||||
"heckel.io/ntfy/util"
|
||||
"html/template"
|
||||
|
@ -238,10 +239,16 @@ func (s *Server) Run() error {
|
|||
errChan <- s.httpsServer.ListenAndServeTLS(s.config.CertFile, s.config.KeyFile)
|
||||
}()
|
||||
}
|
||||
if true {
|
||||
go func() {
|
||||
errChan <- s.mailserver()
|
||||
}()
|
||||
}
|
||||
s.mu.Unlock()
|
||||
go s.runManager()
|
||||
go s.runAtSender()
|
||||
go s.runFirebaseKeepliver()
|
||||
|
||||
return <-errChan
|
||||
}
|
||||
|
||||
|
@ -722,6 +729,21 @@ func (s *Server) updateStatsAndPrune() {
|
|||
s.messages, len(s.topics), subscribers, messages, len(s.visitors))
|
||||
}
|
||||
|
||||
func (s *Server) mailserver() error {
|
||||
ms := smtp.NewServer(&mailBackend{s})
|
||||
|
||||
ms.Addr = ":1025"
|
||||
ms.Domain = "localhost"
|
||||
ms.ReadTimeout = 10 * time.Second
|
||||
ms.WriteTimeout = 10 * time.Second
|
||||
ms.MaxMessageBytes = 1024 * 1024
|
||||
ms.MaxRecipients = 50
|
||||
ms.AllowInsecureAuth = true
|
||||
|
||||
log.Println("Starting server at", ms.Addr)
|
||||
return ms.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *Server) runManager() {
|
||||
for {
|
||||
select {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue