I'm using gomail.v2 to send emails, and my code works fine. After composing a message msg
I can just run
import ("gopkg.in/gomail.v2")
...
d := gomail.NewDialer("smtp.example.com", 25, "username", "password")
return d.DialAndSend(msg)
}
Of course I'd like to generalize this past a particular username and password and separate it into its own function, so I stubbed it out:
import ("gopkg.in/gomail.v2")
...
d := MyDialer()
return d.DialAndSend(msg)
}
func MyDialer() *Dialer {
return gomail.NewDialer("smtp.example.com", 25, "username", "password")
}
But go croaks, complaining that it doesn't know about Dialer.
.\email.go:42: undefined: Dialer
Why is this? I'm using the same return type as NewDialer
, which doesn't cause any problems.
func NewDialer(host string, port int, username, password string) *Dialer
What am I missing? I ran
go get -u gopkg.in/gomail.v2
to make sure I wasn't somehow running an out of date version of the package, but no luck there.