Skip to content

Commit

Permalink
Allow remote authentication to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
decke committed Dec 12, 2018
1 parent ba30ddd commit a70b148
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a70b148

Please sign in to comment.