From a70b1488210f92bfe8bcd6474b898a31b23e0a90 Mon Sep 17 00:00:00 2001 From: Bernhard Froehlich Date: Wed, 12 Dec 2018 08:38:13 +0000 Subject: [PATCH] Allow remote authentication to be optional --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b74661d..9a45ccc 100644 --- a/main.go +++ b/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,