Support LOGIN authentication on outgoing SMTP server

PR:		#1
Obtained from:	https://gist.github.com/andelf/5118732
This commit is contained in:
Bernhard Froehlich
2020-05-15 21:08:17 +00:00
parent 2afbe67407
commit 53c2c27647
4 changed files with 40 additions and 1 deletions

View File

@@ -110,7 +110,14 @@ func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
host, _, _ := net.SplitHostPort(*remoteHost)
if *remoteUser != "" && *remotePass != "" {
auth = smtp.PlainAuth("", *remoteUser, *remotePass, host)
switch *remoteAuth {
case "plain":
auth = smtp.PlainAuth("", *remoteUser, *remotePass, host)
case "login":
auth = LoginAuth(*remoteUser, *remotePass)
default:
return smtpd.Error{Code: 530, Message: "Authentication method not supported"}
}
}
env.AddReceivedLine(peer)