forked from drew/smtprelay
Allow remote authentication to be optional
This commit is contained in:
7
main.go
7
main.go
@@ -27,11 +27,16 @@ var (
|
|||||||
|
|
||||||
func handler(peer smtpd.Peer, env smtpd.Envelope) error {
|
func handler(peer smtpd.Peer, env smtpd.Envelope) error {
|
||||||
|
|
||||||
|
var auth smtp.Auth
|
||||||
host, _, _ := net.SplitHostPort(*remoteHost)
|
host, _, _ := net.SplitHostPort(*remoteHost)
|
||||||
|
|
||||||
|
if *remoteUser != "" && *remotePass != "" {
|
||||||
|
auth = smtp.PlainAuth("", *remoteUser, *remotePass, host)
|
||||||
|
}
|
||||||
|
|
||||||
return smtp.SendMail(
|
return smtp.SendMail(
|
||||||
*remoteHost,
|
*remoteHost,
|
||||||
smtp.PlainAuth("", *remoteUser, *remotePass, host),
|
auth,
|
||||||
env.Sender,
|
env.Sender,
|
||||||
env.Recipients,
|
env.Recipients,
|
||||||
env.Data,
|
env.Data,
|
||||||
|
|||||||
Reference in New Issue
Block a user