Ensure that authentication was successfull before we relay mails

This commit is contained in:
Bernhard Froehlich
2018-12-26 19:35:38 +00:00
parent 72dad9fb70
commit 38aa14ddbf

View File

@@ -122,6 +122,10 @@ func authChecker(peer smtpd.Peer, username string, password string) error {
}
func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
if *allowedUsers != "" && peer.Username == "" {
return smtpd.Error{Code: 530, Message: "Authentication Required"}
}
peerIP := ""
if addr, ok := peer.Addr.(*net.TCPAddr); ok {
peerIP = addr.IP.String()