2
0
Эх сурвалжийг харах

Allow remote authentication to be optional

Bernhard Froehlich 6 жил өмнө
parent
commit
a70b148821
1 өөрчлөгдсөн 6 нэмэгдсэн , 1 устгасан
  1. 6 1
      main.go

+ 6 - 1
main.go

@@ -27,11 +27,16 @@ var (
 
 func handler(peer smtpd.Peer, env smtpd.Envelope) error {
 
+	var auth smtp.Auth
 	host, _, _ := net.SplitHostPort(*remoteHost)
 
+	if *remoteUser != "" && *remotePass != "" {
+		auth = smtp.PlainAuth("", *remoteUser, *remotePass, host)
+	}
+
 	return smtp.SendMail(
 		*remoteHost,
-		smtp.PlainAuth("", *remoteUser, *remotePass, host),
+		auth,
 		env.Sender,
 		env.Recipients,
 		env.Data,