浏览代码

Ensure that authentication was successfull before we relay mails

Bernhard Froehlich 6 年之前
父节点
当前提交
38aa14ddbf
共有 1 个文件被更改,包括 4 次插入0 次删除
  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()