blob: 778dd3b30b16bcd999a35d8b61266191d23401b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package smtp
import (
"dove/config"
"dove/messages"
"dove/utils/logger"
"fmt"
)
var activeServers []serverInstance
func Start() {
plainAddress := fmt.Sprintf("%s:%d", config.SMTP.Host, config.SMTP.Port)
plainServer := createServer(plainAddress)
activeServers = append(activeServers, serverInstance{server: plainServer, label: LOG_PREFIX})
go startListener(plainServer, LOG_PREFIX, plainAddress)
}
func Shutdown() {
for _, instance := range activeServers {
if shutdownError := instance.server.Close(); shutdownError != nil {
logger.Errorf(LOG_PREFIX, messages.SMTPShutdownFailed, instance.label, shutdownError)
}
}
logger.Infof(LOG_PREFIX, messages.SMTPShutdownComplete)
}
|