Browse Source

Ensure that authentication was successfull before we relay mails

Bernhard Froehlich 6 năm trước cách đây
mục cha
commit
38aa14ddbf
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      main.go

+ 4 - 0
main.go

@@ -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()